I need to make a global rule that rewrites all http://example.com/
to https://example.com/
. I host multiple domains and my attempts either don't work or work on all domains.
I put this in my applicationHost.config
:
<globalRules>
<rule name="Rewrite test" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="true" />
</rule>
</globalRules>
<globalRules>
<rule name="kommunetv SSL">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="http://(.*\.kommunetv.no)(/?.*)" />
</conditions>
<action type="Rewrite" url="https://{C:1}{C:2}" appendQueryString="false" />
</rule>
</globalRules>
Tried various match patterns and also attempts with {HTTP_HOST}
conditions. Hoping for some input :)