title: ssl wildcard sub domain www.sub.domain.com
body: <p>I've purshase a wildcard ssl certificat for *.domain.com.
  I use:</p>
  
  <ul>
  <li>startssl provider for ssl certificat</li>
  <li>Apache VirtualHost</li>
  </ul>
  
  <p>I want every request to be redirected to HTTPS NO-WWW</p>
  
  <p>I managed to do this:</p>
  
  <ul>
  <li><strong>http</strong>://sub.domain.com => <strong>https</strong>://domain.com is ok</li>
  <li><strong>http</strong>://<strong>www</strong>.sub.domain.com => <strong>https</strong>://sub.domain.com is ok</li>
  </ul>
  
  <p>BUT </p>
  
  <p><strong>https</strong>://www.sub.domain.com => <strong>https</strong>://domain.com is NOT OK (NET::ERR_CERT_COMMON_NAME_INVALID)</p>
  
  <p>Can you help me ?</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
   ServerName sub.domain.com
   Redirect permanent / https://sub.domain.com
  &lt;/VirtualHost&gt;
  &lt;VirtualHost *:80&gt;
   ServerName www.sub.domain.com
   Redirect permanent / https://sub.domain.com
  &lt;/VirtualHost&gt;
  Listen 443
  &lt;VirtualHost *:443&gt;
   ServerAdmin mail@domain.com
   ServerName sub.domain.com
   ServerAlias www.sub.domain.com
   DocumentRoot  /home/sub.domain.com
   &lt;Directory /&gt;
    Options FollowSymLinks
    AllowOverride None
   &lt;/Directory&gt;
   &lt;Directory  /home/sub.domain.com&gt;
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
   &lt;/Directory&gt;
   SSLEngine on
   SSLProtocol all -SSLv2 -SSLv3
   SSLCipherSuite ALL:!DH:!EXPORT:!RC4:+HIGH:+MEDIUM:!LOW:!aNULL:!eNULL
   SSLCertificateFile   /etc/ssl/2__.sub.domain.com.crt
   SSLCertificateKeyFile  /root/sub.domain.com.key
   SSLCertificateChainFile    /etc/ssl/1_root_bundle.crt 
  &lt;/VirtualHost&gt;
  </code></pre>