i have +10 domains on one solution, and about half of them have had an SSL certificate attached. I seem to have trouble creating ONE rule to make the correct ones being forced onto https.
I can to a rule for each of them, but feel this should have worked:
<rule name="HTTP to HTTPS redirect 1" patternSyntax="ECMAScript" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www.domainNo1.dk$" />
<add input="{HTTP_HOST}" pattern="^www.domainNo2.dk$" />
<add input="{HTTP_HOST}" pattern="^www.domainNo3.dk$" />
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
</rule>
this leaving the domain4, domain5, etc. alone.
Unfortunately it does not kick in when I have more than one domain in the rule. I'm guessing it is the logical grouping that is probably default:
logicalGrouping="MatchAll"
But setting:
logicalGrouping="MatchAny"
will make the sites not work at all. After the redirect to https it continues to redirect the pages, resulting in "ERR_TOO_MANY_REDIRECTS".
I would have thought this was handled by
<add input="{HTTPS}" pattern="off" />
But no.
Hope anyone can help.
You could use below rewrite rule to match multiple domains:
<rule name="http to https with multiple domain name" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="www.sample1.com|www.sample3.com" />
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
</rule>
Regards,
Jalpa
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.