title: .htaccess redirect https to http not working
body: <p>I am trying to catch any https traffic to the front of my site so:</p>
  
  <pre><code>https://www.domain.com
  </code></pre>
  
  <p>is redirected to:</p>
  
  <pre><code>http://www.domain.com
  </code></pre>
  
  <p>However other subdomains need to be redirected elsewhere. For the most part this is all working, apart from the https -> http redirection. Here's my .htaccess file at the moment:</p>
  
  <pre><code>RewriteEngine On
  
  RewriteCond %{HTTPS} on
  RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}
  
  RewriteCond %{HTTP_HOST} ^domain\.com [NC]
  RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
  
  RewriteCond "%{HTTP_HOST}" !^www.* [NC]
  RewriteCond "%{HTTP_HOST}" ^([^\.]+).*$
  RewriteRule ^(.*)$ https://secure.domain.com/a/login/%1 [L,R=301]
  </code></pre>
  
  <p>It would seem that this bit:</p>
  
  <pre><code>RewriteCond %{HTTPS} on
  RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}
  </code></pre>
  
  <p>isn't working as I would imagine. In fact it doesn't seem to redirect at all.</p>
  
  <p>In another subdirectory I have the opposite in effect which works fine:</p>
  
  <pre><code>RewriteCond %{HTTPS} off
  RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
  </code></pre>
  
  <p>so my thinking is the opposite should have done the job, but seemingly not.</p>
  
  <p>Any thoughts anyone?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I'm thinking that this could have something to do with the fact that on the server there is an ssl cert which the ISP uses to provide a generic https address to your site. For example if you have a site at:</p>
  
  <p><a href="http://www.yourdomain.com" rel="nofollow noreferrer">http://www.yourdomain.com</a></p>
  
  <p>You can access the same content/hosting account over https by using:</p>
  
  <p><a href="https://server100.securedomain.com/yourdomain.com" rel="nofollow noreferrer">https://server100.securedomain.com/yourdomain.com</a></p>
  
  <p>Could it be that because when I type in https into the browser I'm being served the generic cert and because it doesn't match the domain name I've entered I'm getting a security warning about an untrusted cert which is stopping the redirection?</p>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>Looking at the server headers I think I am correct with my above assumption. The server is returning:</p>
  
  <pre><code>The host name in the certificate is invalid or does not match
  </code></pre>
  
  <p>Would this stop the redirection?</p>