Posted On August 2, 2019

Microsoft IIS: How to Forward from HTTP to HTTPS

kimconnect 0 comments
blog.KimConnect.com >> Codes >> Microsoft IIS: How to Forward from HTTP to HTTPS

1. Apply the URL Rewrite module as required:
– https://www.iis.net/downloads/microsoft/url-rewrite
– 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. crm.kimconnect.com 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

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

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

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

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

Leave a Reply

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

Related Post

List Folder Sizes

# Powershell Script to list folders sizes Install-Module PSFolderSize $folders = "\\FILESERVER01\SHARE01","C:\Windows\Users\kimconnect" foreach ($folder in…

Install Apps on Remote Computers via WinRM & Chocolatey

Version A: [string[]]$computers=@( 'SERVER01', 'SERVER02', 'SERVER03' ) [string]$chocoAppName='pgadmin4' [version]$minVersion='6.0' $results=[hashtable]@{} foreach ($computer in $computers){ $session=new-pssession…

PowerShell: Scan for Available or Unavailable IPs

This function is a demonstration of multi-tasking using PowerShell. The program will ping multiple targets…