I have now a www -> non-www redirect running:
this has worked well.
--------
Now I have SSL on, and need to 301 redirect all http requests to matching https content.
Also, ://www.mydomain.com to ://mydomain.com
I suck at rewrite code.
Web is full of solutions, and they are almost all different. What is your proposal? I really can not start testing these on a live site without being absolutely sure they work.
This looks most sane (from https://simonecarletti.com/blog/2016/08/redirect-domain-http-https-www-apache/):
Is there any difference to this:
or, is there a better solution. Google absolutely requires a 301 redirect (so that they can simply update their index and not reindex the site), so I hope for a solution that does it cleanly. I have certificates working for both www and non-www.
Thanks a lot.
Code:
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://mydomain.com/$1 [R=301,L]
--------
Now I have SSL on, and need to 301 redirect all http requests to matching https content.
Also, ://www.mydomain.com to ://mydomain.com
I suck at rewrite code.
Web is full of solutions, and they are almost all different. What is your proposal? I really can not start testing these on a live site without being absolutely sure they work.
This looks most sane (from https://simonecarletti.com/blog/2016/08/redirect-domain-http-https-www-apache/):
Code:
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://mydomain.com%{REQUEST_URI} [L,NE,R=301]
Code:
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$ [NC]
RewriteRule ^(.*)$ https://mydomain.com/$1} [R=301,L]
or, is there a better solution. Google absolutely requires a 301 redirect (so that they can simply update their index and not reindex the site), so I hope for a solution that does it cleanly. I have certificates working for both www and non-www.
Thanks a lot.
Last edited by a moderator: