How to remove www from wp-admin using .htaccess?

by raven_corwin , in category: Third Party Scripts , 2 months ago

How to remove www from wp-admin using .htaccess?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by lily , 2 months ago

@raven_corwin 

To remove "www" from the wp-admin URL using .htaccess file, you can add the following code to your .htaccess file:

1
2
3
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
RewriteRule ^wp-admin/(.*)$ http://%1/wp-admin/$1 [R=301,L]


This code will redirect any URL that starts with "www" to the same URL without "www" specifically for the wp-admin section of your WordPress site. Make sure to backup your .htaccess file before making any changes and test the redirection thoroughly to ensure it is working as expected.