Microsoft IIS: How to Forward from HTTP to HTTPS

1. Apply the URL Rewrite module as required:
– Extract and install it

2. Run InetMgr.exe > select the target website > double-click on Url Rewrite > click “Add Rule(s)” from the right-side menu > high-light “Blank rule” > OK > give this rule a name (e.g. HTTP to HTTPs) > Set the Inbound Rule as follows:
– Requested URL = Matches the Pattern
– Using = Regular Expressions
– Pattern = (.*)
– Ignore Case = checked

At Conditions window > set Logical grouping = Match All > click Add
— Condition Input = {HTTPS}
— Check if input string = Matches the Pattern
— Pattern = ^OFF$
— Ignore case = checked

At Action window > make these settings > click Apply when done
– Action type = Redirect
– Action Properties
— Redirect URL = https://{HTTP_HOST}{REQUEST_URI} OR https://{HTTP_HOST}/{R:1}
— Append query string = checked
— Redirect type = Permanent (301)

Double-click SSL Setting > ensure Require SSL is not checked

Right-click the website > Explore > locate web.config (if exists) > ensure that the following content exists within that file

<add name="WebApiUrlRewriteModule" type="Microsoft.Crm.Application.Components.Modules.WebApiUrlRewriteModule, Microsoft.Crm.Application.Components.Application, Version=, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx" preCondition="managedHandler" />

If the WebApiUrlRewriteModule is not defined, add this <rewrite> rule:

<!-- Added by KimConnect 8/15/19
URL Rewrite to enforce HTTP forwarding to HTTPS
<rule name="HTTPS force" enabled="true" stopProcessing="true">
<match url="(.*)" />
<add input="{HTTPS}" pattern="^OFF$" />
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
<!-- Added by KimConnect 8/15/19
URL Rewrite to enforce HTTP forwarding to HTTPS

Perform IISreset > verify that automatically forwards to; otherwise, reverse the changes and call Mr Google.

Posted on Categories Codes

Leave a Reply

Your email address will not be published. Required fields are marked *