I am looking for a set of rewrite rules that will do the following:
You could also say i want all url's that aren't equal to https://www.somedomain.com, rewritten to https://www.somedomain.com.
I have seen a lot of answers, but i couldn't find a set of rewrite rules that matches the above and difficulty combining some of them to one solid set of rules that will accomplish the above.
Thanks in advance!
You can use this single rule for that in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?:www\.)?somedomain1\.com$
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^ https://www.somedomain1.com%{REQUEST_URI} [NE,R=301,L]
RewriteCond %{HTTP_HOST} ^(?:www\.)?somedomain2\.com$
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^ https://www.somedomain2.com%{REQUEST_URI} [NE,R=301,L]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With