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:
- 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
- Open [URL Rewrite] > under 'Inbound rules select [Blank rule] > OK
- 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
- Under 'Conditions', leave [Match All] > [Add] to define the following;
Input = {HTTPS}Type = Match the PatternPattern = OFF - Under 'Action', define the following:
Action type = RedirectRedirect URL = https://{HTTP_HOST}/{R:0}Select 'Append query string' checkboxRedirect type = Permanent (301)
This will apply the configuration automatically. The above creates the following in the web.config;