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

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

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

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by lily , 9 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.

Related Threads:

How to remove url parameters in php using .htaccess?
How to remove part of url using .htaccess?
How to remove a redirect in .htaccess?
How to remove .cgi from url with .htaccess?
How to remove .php .html via .htaccess?
How to remove the .php extension in .htaccess file?