I need to redirect one domain https://www.mydomain.com to https://mydomain.com.
I use this .htaccess and it not work for me.
Previously i have the ssl cert for https://www.mydomain.com
and it was broke, we register the new ssl for the host https://mydomain.com
In the WHM there is only one ssl host but in the cpanel there are two hosts one is old www.mydomain.com
and mydomain.com
(Is this effect on the redirection?)
the .htaccess is below.
RewriteEngine on
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$ [NC]
RewriteRule ^(.*)$ https://mydomain.com/$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com$ [NC]
RewriteRule ^(.*)$ https://mydomain.com/$1 [R=301,L]
I am getting the security alert always while i type https://www.mydomain.com
.
What the mistake that i did here?
Thanks in advance