Redirect from HTTP to HTTPS using IIS URL Rewrite
In case of problems with HTTP and HTTPS redirection, set up automatic redirection in IIS server using URL Rewrite.
How to redirect from HTTP to HTTPS
-
Make sure you have IIS intranet server installed.
-
Download the URL Rewrite module and install it, see link below.
-
Ensure that port 80 is configured on the page you want to redirect to.
-
After installing the URL Rewrite module, its icon will appear in the page overview window in IIS Manager. If it does not appear, try to restart IIS.
-
Select the page, open URL Rewrite, select the Add Rule(s) action in the right pane. In the Add Rule(s) window select the Blank rule option and confirm.
-
In the open form, set the following:
- Enter a name.
- Match URL:
- Select Requested URL from the Requested URL menu matches the Pattern.
- Select Using from the Wildcards menu.
- Enter
*
in the text box and check the Ignore case.
- Conditions:
- From the Logical grouping menu, select Match Any.
- Select Add.
In the window that opens, in the Condition input
type
{HTTPS}
, select Matches the Pattern, enter off in the last field and confirm.
- Action:
- Select Redirect from the selection.
- In the text box, type
https://{HTTP_HOST}{REQUEST_URI}
. - Do not enable/disable the Append query string.
- Select Permanent (301) from the Redirect type menu.
-
In the actions on the right side, confirm the rule by clicking on Apply.
-
The rule is added and can be turned off/on using enable, disable.
Adding a rule using URL rewrite will be reflected in the web.config file as follows:
<rewrite>
<rules>
<rule name="Redirect to http" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" negate="false" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
This modification interferes with IIS settings. This is not a modification to the Alvao configuration.
For more information, see Redirect from HTTP to HTTPS using the IIS URL Rewrite module.