YaWb
1
How can I fix a canonicalization issue?
My website is registered as https://mywebsite.com. Unfortunately, https://www.mywebsite.com does not redirect to https://mywebsite.com.
On my Apache server, I used
#+WebsiteRedirect
RewriteEngine On
RewriteOptions InheritBefore
RewriteCond “%{HTTP_HOST}” “mywebsite.com$”
RewriteCond “%{REQUEST_URI}” “^/http://www.mywebsite.com”
RewriteRule “." “http://mywebsite.com” [L,R=301]
RewriteCond “%{HTTP_HOST}” “^mywebsite.com[.]”
RewriteCond “%{REQUEST_URI}” “^/http://www.mywebsite.com”
RewriteRule ".” “http://mywebsite.com” [L,R=301]
#-WebsiteRedirect
To redirect.
Unfortunately, it doesn’t work. What did I do wrong?
Thanks,
Yuka
Allan
2
Hello
Try this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(mywebsite\.com)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [L,R=301]
YaWb
3
Hi Allan! Thanks a lot. Your solution does improve the situation, but not completely, because subpages are not redirected. For example, I have no problems with https://mywebsite.com and https://www.mywebsite.com redirections, but mywebsite.com - Diese Website steht zum Verkauf! - Informationen zum Thema mywebsite. mywebsite.com - Diese Website steht zum Verkauf! - Informationen zum Thema mywebsite. do not redirect. Can you help a bit more? Thanks a lot
YaWb
4
YaWb
5