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.
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.
The main site rule seems to be overriding the subfolder rule.
Main site rule:
<rule name="Force HTTPS" enabled="true">
<match url="(.*)" ignoreCase="false" />
<conditions>
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
Subfolder rule (in its own web.config file):
<rule name="Force HTTP" enabled="true" stopProcessing="true">
<match url="(^subfoldersite/.*)" ignoreCase="true" />
<conditions>
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
I have tried without a subfolder rule but same thing happens