Doc is wrong about using "Redirect URL: https://{HTTP_HOST}/{R:1}" though. Using https://{HTTP_HOST}{REQUEST_URI} is better.
-Add blank url rewrite rule under directory you want to start at
- Enter “Redirect to HTTPS” in the name field.
- Next we will configure the first configuration pull down box called “Match URL”, on the right side of “Match URL” press the down arrow to expand the box.
Requested URL: Matches the Pattern
Using: Regular Expressions
Pattern: (.*)
Condition Input: {HTTPS}
Check if input string: Matches the Pattern
Pattern: ^OFF$
Action Type: Redirect
Redirect URL: https://{HTTP_HOST}{REQUEST_URI}
Redirect Type: See Other (303)
My resulting web.config:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to HTTPS" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="SeeOther" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>