title: https on subdomain redirects to main domain; subdomain works without https
body: <p>I have a website, <code>https://www.example.com</code> and subdomain, <code>https://sub.example.com</code>.</p>
  
  <p>My problem is that whenever I try to visit <code>https://sub.example.com</code> I am redirected to <code>https://www.example.com</code>. But, when I visit <code>http://sub.example.com</code>, I am not redirected.</p>
  
  <p>I have a wildcard SSL cert which should allow me to visit my subdomain with <code>https://</code>. Both sites run WordPress and are hosted with Bluehost. I have tried many solutions as well as contacting Bluehost customer support twice to no avail. I would like to be able to visit both my main domain and subdomain with SSL active.</p>
  
  <p>I have edited the <code>.htaccess</code> file according to the following solutions found here: <a href="https://stackoverflow.com/questions/29088257/htaccess-redirect-domain-to-https-subdomain-to-http-and-www-to-non-www">htaccess redirect domain to https, subdomain to http and www to non-www</a></p>
  
  <pre><code># for main domain
  RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
  RewriteCond %{HTTPS} off [OR]
  RewriteCond %{HTTP_HOST} ^www\. [NC]
  RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L,NE]
  
  # for sub domain
  RewriteCond %{HTTP_HOST} ^(www\.)?sub\.example\.com$ [NC]
  RewriteCond %{HTTPS} on [OR]
  RewriteCond %{HTTP_HOST} ^www\. [NC]
  RewriteRule ^ http://sub.example.com%{REQUEST_URI} [R=301,L,NE]
  </code></pre>
  
  <p><a href="https://my.bluehost.com/hosting/help/766" rel="nofollow noreferrer">https://my.bluehost.com/hosting/help/766</a></p>
  
  <pre><code># Custom subdomain .htaccess SSL + WordPress
  RewriteEngine On
  RewriteCond %{HTTP_HOST} ^subdomain.maindomain.com$
  RewriteCond %{REQUEST_URI} !^/subfolder/
  RewriteRule ^(.*)$ /subfolder/$1
  RewriteCond %{HTTP_HOST} ^subdomain.maindomain.com$
  RewriteRule ^(/)?$ subfolder/index.php [L]
  # End custom subdomain .htaccess
  
  # Custom maindomain .htaccess WordPress
  RewriteEngine On
  RewriteBase /
  RewriteCond %{HTTP_HOST} ^(www.)?maindomain.com$
  RewriteRule ^index\.php$ - [L]
  RewriteCond %{HTTP_HOST} ^(www.)?maindomain.com$
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.php [L]
  # End custom maindomain .htaccess
  </code></pre>
  
  <p><a href="http://www.wpbeginner.com/wp-tutorials/how-to-add-ssl-and-https-in-wordpress/" rel="nofollow noreferrer">http://www.wpbeginner.com/wp-tutorials/how-to-add-ssl-and-https-in-wordpress/</a></p>
  
  <p>I have also tried fresh WordPress installs of both the main domain and subdomain with no luck. I'm not sure what else to try. Any help and suggestions would be much appreciated.</p>