Forum Moderators: phranque
https://www.domain.com https://domain.com to goto my primary url above. http://domain.com goto primary url. http://www.domain.com goto primary url. https://domain.com ? Can anyone please check and correct the rule above? Apologies for the format of the text. Thanks much!
# non-www to www redirect
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^ https://www.example.com%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+?)\.?$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L]
https://www.domain.comUse example.com.
RewriteCond %{REQUEST_URI} !^/robots\.txt
because I’ve seen some robots get confused if a robots.txt request is redirected, and you don’t want to give them any excuse to say “But I tried to get robots.txt ::whine:: honest I did”.
http://example.com ==> https://www.example.comBut Google removed the link juice dilution with 301 redirects some time ago and instead started to push the HSTS preload list. To get on the HSTS preload list you have to redirect from http to https without a secondary DNS lookup as @w3dk correctly mentioned. Therefore now the recommended sequence has changed to: http://example.com ==> https://example.com ==> https://www.example.comI do not know if Google is currently already using inclusion on the HSTS preload list as a signal for better ranking in the SERPs, but knowing how Google is pushing secure sites, I have no doubt that somewhere in the future they will use the HSTS preload list in some way to rank URLs in the SERPs. the recommendation was to go to the final URL in just one 301 redirect to prevent link juice to dilute too muchI must take issue with this. The primary reason for doing any redirect--of which hostname canonicalization is only one subset--in a single step was to save work for the server. It potentially also saves response time for users with slow connections (or, worst case, sites with slow servers).
https://www.domain.comUse example.com.
Use example.com.
Use example.com.