301 redirect from www to non-www has no effect
-
I have recently migrated from multiple wordpress to multisite and I have also changed the main domain (therefore I have a brand new website). Everything seems to work fine except the www to non-www redirect. After reading a lot of stuff, I tried different methods of accomplishing this but it still doesn’t do it.
I contacted the hosting service (they have no CPanel installed so every time I have a problem I have to contact them and hope they will resolve it) and they said everything is ok on their back-end so it must be something with the 301 redirect. My previous domain was also hosted on the same server and the redirection worked fine. Even now, it redirects from both de www and the non-www version of the old domain to the non-www version of the new one, just as it should. The only thing that does not work is redirecting the www to non-www on the new domain.
This is how my htaccess looks like (guess this is pretty standard):
RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] # uploaded files RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L] # add a trailing slash to /wp-admin RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L] RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L] RewriteRule . index.php [L]
I’ve been tryin to add this after de “RewriteEngine On” line:
RewriteCond %{HTTP_HOST} ^www\.domain\.tld$ [NC] RewriteRule ^(.*)$ https://domain.tld/$1 [R=301,L]
(of course, using the right domain and tld).
Is there anything I should do different? Is there something I should ask the hosting agency?
- The topic ‘301 redirect from www to non-www has no effect’ is closed to new replies.