I'm trying to enforce https and a www prefix. However my rule doesn't fully work. Here is my rule:
<rewrite>
<rules>
<clear />
<rule name="Force https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://www.mydomain.co.uk/{R:1}" redirectType="Permanent" />
</rule>
<rule name="Force www" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="localhost" negate="true" />
<add input="{HTTP_HOST}" pattern="www.mydomain.co.uk" negate="true" />
</conditions>
<action type="Redirect" url="https://www.mydomain.co.uk/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
- It works for redirecting http to https.
- it works if I go to https://mydomain.co.uk (redirects to https://www.mydomain.co.uk)
- however it DOES NOT work if I go to https://mydomain.co.uk/blah/whatever
Please can somebody advise? Thanks.
See Question&Answers more detail:os