title: Web.config redirect from http to https for some sub-site
body: <p>So Ive been googling and browsing similar topics on SO for a while now without finding a solution and figured I might just ask.</p>
  
  <p>I have a master site with several child sites/pages.
  In my Web.config file for the master site (affecting all child sites/pages) I have the following rule:</p>
  
  <pre><code>&lt;rule name="Redirect to https"&gt;
    &lt;match url="(.*)"/&gt;
    &lt;conditions&gt;
      &lt;add input="{HTTPS}" pattern="Off"/&gt;
      &lt;add input="{REQUEST_METHOD}" pattern="^get$|^head$"/&gt;
    &lt;/conditions&gt;
    &lt;action type="Redirect" url="https://{HTTP_HOST}/{R:1}"/&gt;
  &lt;/rule&gt;
  </code></pre>
  
  <p>This rule redirect all requests to any page/site under the master site to https:// which have been the intention for some time.</p>
  
  <p>Now however, I have 4 child sites (4 pages under the master site with their own URLs) which I do not want to use https:// for. Lets call them www.apa.com, www.bepa.com, www.cepa.com, www.depa.com. I read some comment on <a href="https://serverfault.com/questions/292374/redirect-users-from-https-to-http-via-iis-and-the-web-config-file">this similar topic</a> that said it is possible to make exclusions in rules like this, but I did not get it to work.</p>
  
  <p>So I guess I am looking for either a seperate rule or some exclusion to this current rule, that keeps http for my four new child sites and redirects all other sites/pages to https (as it is currently). </p>
  
  <p><strong>EDIT:</strong>
  So I took a different approach. Now I am instead trying to say which sites should redirect to https. The following regex seems to work perfect in a regex tester, but when applied in the web.config file, nothing happens:</p>
  
  <pre><code>^(https?:\/\/)?(something\.somethingelse\.com\/?)(.*)$
  </code></pre>
  
  <p>If this regex is matched, Id like to redirect all requests to https and if it is not matched it should remain http. In the web.config file this looks like:</p>
  
  <pre><code>&lt;rewrite&gt;
    &lt;rules&gt;
      &lt;rule name="Redirect to https"&gt;
        &lt;match url="/^(https?:\/\/)?(something\.somethingelse\.com\/?)(.*)$/"/&gt;
        &lt;conditions&gt;
          &lt;add input="{HTTPS}" pattern="Off"/&gt;
          &lt;add input="{REQUEST_METHOD}" pattern="^get$|^head$"/&gt;
        &lt;/conditions&gt;
        &lt;action type="Redirect" url="https://{HTTP_HOST}/{R:1}"/&gt;
      &lt;/rule&gt;
    &lt;/rules&gt;
  &lt;/rewrite&gt;
  </code></pre>
  
  <p>However this doesnt seem to do anything. Its like it is not possible to match on a full URL or something.</p>