Here is the broken piece of the rewrite rules
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://www.example.com/TEST_SITE/{R:1}"
redirectType="Permanent" />
</rule>
</rules>
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)
If I change the url="https://www.example.com/TEST_SITE/{R:1} to url="{HTTP_HOST}/{R:1}", it will work, no more loop. But instead of redirecting me to https://www.example.com/TEST_SITE/, it redirects me to https://www.example.com/ (prod environment).
Any ideas to fix this ? Thanks
url="https://www.example.com/TEST_SITE/{R:1}"
tourl="https://{HTTP_HOST}/TEST_SITE/{R:1}"
? There are more HTTP to HTTPS redirect examples on stackoverflow.com/a/14925644/1297898 and saotn.org/iis-url-rewrite-redirect-http-to-https. Sometimes it takes some fiddling :) – Jan Reilink