Strange canonical URLs problem
When I type https://www.mysite.com, https:// mysite.com, http://www.mysite.com or https:// mysite.com into my browsers I see this https://www. mysite.com/ Yes, it’s ok.
But Siteliner accessed the site using both https://www. mysite.com/ and https:// mysite.com/. Siteliner received the same content, but different HTTP codes: 200 and 301 respectively.
Seositechecker suggests putting this code in my .htaccess file to fix stuff.
RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
My current code is;
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.mysite.com/$1 [R,L]
Do you have any idea on that issue, please?
Thank you.
When I type https://www.mysite.com, https:// mysite.com, http://www.mysite.com or https:// mysite.com into my browsers I see this https://www. mysite.com/ Yes, it’s ok.
But Siteliner accessed the site using both https://www. mysite.com/ and https:// mysite.com/. Siteliner received the same content, but different HTTP codes: 200 and 301 respectively.
Seositechecker suggests putting this code in my .htaccess file to fix stuff.
RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
My current code is;
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.mysite.com/$1 [R,L]
Do you have any idea on that issue, please?
Thank you.
You will need to setup .htaccess redirection to either the www or non-www website, depending on how you've installed OpenCart. You can use the .htaccess codes you've pasted above, but some minor changes will be needed to have it point to the correct website. Alternatively, you can use the below.
After
Add
After
Code: Select all
RewriteBase /
Code: Select all
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Thank you, MarketInSG.
Please take a look at this code;
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) https://www.%{HTTP_HOST}/$1 [R=301]
RewriteRule ^(.*)$ https://www.mysite.com/$1 [R,L]
What's wrong there?
Please take a look at this code;
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) https://www.%{HTTP_HOST}/$1 [R=301]
RewriteRule ^(.*)$ https://www.mysite.com/$1 [R,L]
What's wrong there?
You have 2 rewrite rules and I would suggest trying MarketinSG suggested rules. You can put a # before each line of your existing rules to temporarily disable them while you try the new rules.genegrin wrote: ↑Wed Oct 03, 2018 10:30 pmThank you, MarketInSG.
Please take a look at this code;
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) https://www.%{HTTP_HOST}/$1 [R=301]
RewriteRule ^(.*)$ https://www.mysite.com/$1 [R,L]
What's wrong there?
Opencart Hosting Plans, Domain Registration, Microsoft and Google Email and More
Visit our website for great deals and most importantly, fast and friendly support - www.evolvewebhost.com
Active Member
Different tools show the different results. How is it possible?
For example, Siteliner still accessed my site using both https://www. and https:// . Siteliner received the same content, but different HTTP codes: 200 and 301 respectively.
For example, Siteliner still accessed my site using both https://www. and https:// . Siteliner received the same content, but different HTTP codes: 200 and 301 respectively.
It must be "example.com" to "www.example.com" and then that gets redirected to "https:www.example.com".
What's the code? Suggest please.
What's the code? Suggest please.
The correct way to also be compatible with HSTS would be to redirect to https then to www. Try the code below. Notice the E=HTTPS flag, which ensures that only https requests are redirected to www.
Code: Select all
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule .* https://www.example.com/$1 [E=HTTPS,R=301,L]
How do you test your sites for URL Canonicalization Issues, please?
Google and these tools didn’t find canonicalization problems with my site:
SeoSiteCheckup,
Seoreviewtools,
seoprofiler,
coderseo.
However, varvy.com/tools/redirects shows this.
Google and these tools didn’t find canonicalization problems with my site:
SeoSiteCheckup,
Seoreviewtools,
seoprofiler,
coderseo.
However, varvy.com/tools/redirects shows this.
Attachments
2018.png (39.34 KiB) Viewed 1454 times
I just check manually using the web browsers network inspect tool. You could do it all in one step using something like the code below. However some security scanners (such as https://observatory.mozilla.org/) will flag this up as being a redirect to a different host, preventing HSTS for being set for the domain. https://infosec.mozilla.org/guidelines/ ... directions
Code: Select all
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule .* https://www.example.com/$1 [R=301,L]
Who is online
Users browsing this forum: No registered users and 274 guests