title: IIS rewrite rule within subfolder
body: <p>I have 2 separate sites. One site is within a subfolder of the main site. I need to force HTTPS to both sites but keeping the query string intact as users can enter the site from internal pages.</p>
  
  <p>The issue I am having is when I try to add the IIS rewrite rule for the subfolder site it redirects to the main site.</p>
  
  <p>The main site rule seems to be overriding the subfolder rule.</p>
  
  <p>Main site rule:</p>
  
  <pre><code>&lt;rule name="Force HTTPS" enabled="true"&gt;
      &lt;match url="(.*)" ignoreCase="false" /&gt;
      &lt;conditions&gt;
          &lt;add input="{HTTPS}" pattern="off" /&gt;
      &lt;/conditions&gt;
      &lt;action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" /&gt;
  &lt;/rule&gt;
  </code></pre>
  
  <p>Subfolder rule (in its own web.config file):</p>
  
  <pre><code>&lt;rule name="Force HTTP" enabled="true" stopProcessing="true"&gt;
      &lt;match url="(^subfoldersite/.*)" ignoreCase="true" /&gt;
      &lt;conditions&gt;
          &lt;add input="{HTTPS}" pattern="off" /&gt;
      &lt;/conditions&gt;
      &lt;action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" /&gt;
  &lt;/rule&gt;
  </code></pre>
  
  <p>I have tried without a subfolder rule but same thing happens</p>