title: Isapi Rewrite - preserving HTTPS in redirects behind load balancer
body: <p>I'm running a site which has 2 separate sub-domains - one for HTTP and another for HTTPS.</p>
  
  <ul>
  <li><code>http://www.example.com</code></li>
  <li><code>https://secure.example.com</code></li>
  </ul>
  
  <p><code>http://secure.example.com</code> does not exist and will not resolve.</p>
  
  <p>The problem is that the site is running behind a load balancer which handles all SSL. Communication between the load balancer and the web servers in always HTTP.</p>
  
  <p>So, when using Isapi Rewrite 3 (a mod_rewrite clone for IIS) to implement some redirects I'm running into a problem.</p>
  
  <p>As far as Isapi Rewrite is concerned HTTPS is turned off - so redirects on <code>secure.example.com</code> are failing.</p>
  
  <p>Say I have a rule which says:</p>
  
  <pre><code>RewriteRule ^/example/$ /test/ [R=301,L]
  </code></pre>
  
  <p>If I make a request for <strong><code>https://secure.example.com/example/</code></strong> I would like to end up on <strong><code>https://secure.example.com/test/</code></strong> but, because Isapi Rewrite sees HTTPS as OFF, I end up on  <strong><code>http://secure.example.com/test/</code></strong>.</p>
  
  <p>Is there any way I can force redirects to be to HTTPS if the domain is <code>secure.example.com</code>?</p>
  
  <p>Something along the lines of this:</p>
  
  <pre><code>RewriteCond %{SERVER_NAME} secure.example.com
  RewriteRule ^/(.*)$ https://secure.example.com/$1
  </code></pre>
  
  <p>Except that doesn't work - it immediately forces an explicit redirect, whereas I want to continue processing other <code>RewriteRules</code>.</p>
  
  <p>Thanks,</p>
  
  <p>Stu</p>