IIS URL Rewrite

This IIS extension provides the ability to create rewrite rules, ie: HTTP and HTTPS. Read more here. Start by downloading and install the URL Rewrite Module for IIS.

In this example, we will create a HTTPS redirect rule:
  1. Under IIS snap-in, Untick 'Require SSL' under [SSL Settings] for the desired site or for the 'Default Web Site' if the site falls under it

  2. Open [URL Rewrite] > under 'Inbound rules select [Blank rule] > OK

  3. Under 'Match URL' option, leave [Match the Pattern] under 'Required URL' and [Regular Expressions] under 'Using' as default. Under 'Patterns', enter .* and leave 'Ignore case' ticked

  4. Under 'Conditions', leave [Match All] > [Add] to define the following;

    Input = {HTTPS}
    Type = Match the Pattern
    Pattern = OFF
  5. Under 'Action', define the following:

    Action type = Redirect
    Redirect URL = https://{HTTP_HOST}/{R:0}
    Select 'Append query string' checkbox
    Redirect type = Permanent (301)

This will apply the configuration automatically. The above creates the following in the web.config;

            <rule name="HTTP to HTTPS redirect" stopProcessing="true">
                <match url=".*" />
                    <add input="{HTTPS}" pattern="OFF" />
                <action type="Redirect" url="https://{HTTP_HOST}/{R:0}" redirectType="Permanent" />