title: htaccess redirects with subdomains and https
body: <p>I'm working with a HostGator account that is hosting two domains (both using SSL). I also have subdomains set up on both of these that don't use the SSL. I have a redirect set up so that http will redirect to https, but I'm having problems working with the subdomains.</p>
  
  <p>Here is what I need it to do:</p>
  
  <p><a href="http://site1.com" rel="nofollow">http://site1.com</a> -> <a href="https://site1.com" rel="nofollow">https://site1.com</a></p>
  
  <p><a href="http://www.site1.com" rel="nofollow">http://www.site1.com</a> -> <a href="https://site1.com" rel="nofollow">https://site1.com</a></p>
  
  <p>dev.site1.com -> no redirect</p>
  
  <p><a href="http://site2.com" rel="nofollow">http://site2.com</a> -> <a href="https://site2.com" rel="nofollow">https://site2.com</a></p>
  
  <p><a href="http://www.site2.com" rel="nofollow">http://www.site2.com</a> -> <a href="https://site2.com" rel="nofollow">https://site2.com</a></p>
  
  <p>dev.site2.com -> no redirect</p>
  
  <p>What is happening now is that when I go to dev.site2.com (whether or not I put in https) what I see is <a href="https://site1.com" rel="nofollow">https://site1.com</a>, although it doesn't appear to be redirecting, because the address bar still shows dev.site2.com</p>
  
  <p>Here is what I have in htaccess: </p>
  
  <pre><code>RewriteEngine On
  RewriteBase /~hostgatorusername/
  RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
  RewriteCond %{HTTP_HOST} !=dev.*
  RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
  RewriteCond %{HTTPS} !=on
  RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
  
  
  # BEGIN WordPress
  &lt;IfModule mod_rewrite.c&gt;
  
  RewriteEngine On
  RewriteBase /~hostgatorusername/
  RewriteRule ^index\.php$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /~hostgatorusername/index.php [L]
  &lt;/IfModule&gt;
  
  # END WordPress
  </code></pre>
  
  <p>I'm still trying to fully grasp htaccess, so I'd love if someone could help me understand what I'm doing wrong. Thanks!</p>
  
  <p>Update: I also need <a href="https://www.site1.com" rel="nofollow">https://www.site1.com</a>  to redirect to  <a href="https://site1.com" rel="nofollow">https://site1.com</a> and 
  <a href="https://www.site2.com" rel="nofollow">https://www.site2.com</a>  to redirect to  <a href="https://site2.com" rel="nofollow">https://site2.com</a></p>