I'm running IIS 7.5 on a server with multiple sites configured. I am new to using this tool, as well as XML. I'd like to see if I can get some suggestions on how to fix what's going on.
Here's what I'm trying to do:
1. When someone hits the server, force all to HTTPS.
2. When someone hits the web address https://web1.domain.com/test/home,https://web1.domain.com/test2/home, orhttps://web1.domain.com/test3/home continue to the page, and stop processing more rules (to prevent loops, if this is even necessary).
3. Redirect everything that is not one of the three addresses listed in #2 to go to the first one, https://web1.domain.com/test/home.
Here's what I currently have:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="force https" enabled="false" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" />
</rule>
<rule name="mobile https off" enabled="false" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="false">
<add input="{HTTPS}" matchType="Pattern" pattern="^web1/.domain/.com/test/home" ignoreCase="true" negate="false" />
</conditions>
<action type="None" />
</rule>
<rule name="https off" enabled="false" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="false">
<add input="{HTTPS}" pattern="^web/.domain/.com/test2/home" />
</conditions>
<action type="None" />
</rule>
<rule name="https con off" enabled="false" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTPS}" matchType="Pattern" pattern="^web1/.domain/.com/test3/home" ignoreCase="true" negate="false" />
</conditions>
<action type="None" />
</rule>
<rule name="rewrite all but exact matches" enabled="false" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTPS}" pattern="^web1/.domain/.com/test/home" negate="true" />
</conditions>
<action type="Redirect" url=https://web1/.domain/.com/test/home appendQueryString="false" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
I have these rules, but keep seeing a redirect loop on the last rule in particular. The http to https redirect at the beginning seems to work fine.
EDIT: One thing I did find was that I had created the rules at the 'Default Web Site' level, and they were propagated to all the sub sites. I manually removed them from the sub sites, just in case that's causing issues.