We have just bought the .com extension for our domain and we are using ssl certificates on both of them:
https://www.domain.net
https://www.domain.com
Now we would like to use the .com extension only and redirect our users from the old domain to the new one using the htaccess file:
http[s]://domain.net -------|
http[s]://www.domain.net ---|---> https://www.domain.com
http[s]://domain.com -------|
I am not very familiar with htaccess so I tried:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^http[s]?://(www\.)?domain\.com(.*)?$
RewriteRule ^(.*)$ http[s]?://www.domain.com/? [R,L]
That obviously doesn't work!
Any help would be greatly appreciated.
E.g.: RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} ^www.example.com/$ [NC] RewriteRule ^(. *)$ http://www.example.com [R=301,L] ... @BobbyS I used the solution in this article. It redirects www and HTTP to non-www HTTPS and also handles the trailing / .
You cannot match scheme http://
in RewriteCond %{HTTP_HOST}
.
You can use this rule:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
RewriteRule ^ https://www.domain.com%{REQUEST_URI} [R=302,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