title: Redirect all https://www.mydomain.com to https://mydomain.com using htaccess (2 SSL HOST in cpanel)
body: <p>I need to redirect one domain <code>https://www.mydomain.com to https://mydomain.com.</code> I use this .htaccess and it not work for me.</p>
  
  <p>Previously i have the ssl cert for <code>https://www.mydomain.com</code> and it was broke, we register the new ssl for the host <code>https://mydomain.com</code></p>
  
  <p>In the WHM there is only one ssl host but in the cpanel there are two hosts one is old <code>www.mydomain.com</code> and <code>mydomain.com</code> (Is this effect on the redirection?)</p>
  
  <p>the .htaccess is below.</p>
  
  <pre><code>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]
  </code></pre>
  
  <p>I am getting the security alert always while i type <code>https://www.mydomain.com</code>.</p>
  
  <p>What the mistake that i did here?</p>
  
  <p>Thanks in advance </p>