title: redirect http to https Infinity loop 301 IIS(load balancing environment)
body: <p>Here is the broken piece of the rewrite rules</p>
  
  <pre><code>    &lt;rules&gt;
                      &lt;rule name="HTTP to HTTPS redirect" stopProcessing="true"&gt;
                          &lt;match url="(.*)" /&gt;
                          &lt;conditions&gt;
                              &lt;add input="{HTTPS}" pattern="off" ignoreCase="true" /&gt;
                          &lt;/conditions&gt;
                          &lt;action type="Redirect" url="https://www.example.com/TEST_SITE/{R:1}"
                                  redirectType="Permanent" /&gt;
                      &lt;/rule&gt;
      &lt;/rules&gt;
  </code></pre>
  
  <p>My intention is to test if redirect http to https works on my test site, however,it will be a infinity loop with code 301 (Moved Permanently)</p>
  
  <p>If I change the url="https://www.example.com/<strong>TEST_SITE</strong>/{R:1} to url="{HTTP_HOST}/{R:1}", it will work, no more loop. But instead of redirecting me to <a href="https://www.example.com/TEST_SITE/" rel="nofollow">https://www.example.com/TEST_SITE/</a>, it redirects me to <a href="https://www.example.com/" rel="nofollow">https://www.example.com/</a> (prod environment).</p>
  
  <p>Any ideas to fix this ? Thanks</p>