Problem with canonicalization

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

Hello :wave:t2: Try this:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(mywebsite\.com)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [L,R=301]

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

Also https://www.mywebsite.com does not redirect back to https://mywebsite.com, only https://mywebsite.com redirects to https://www.mywebsite.com

Also, no redirection happens for blog pages: mywebsite.com - Diese Website steht zum Verkauf! - Informationen zum Thema mywebsite.