Share via


Windows IIS : Create URL Rewrite rule for IIS web site redirect

In this post, we will see that in a few simple steps we can create a URL Rewrite to redirect website traffic from HTTP to HTTPS.

What is URL Rewrite Module

The URL Rewrite Module is an extension for IIS. This module gives the ability to Web Administrators to implement rules which can improve the usability and search friendliness of a website.

Prerequisites

  • IIS 7 or higher
  • URL Rewrite module installed. Download URL Rewrite 2.1 module from this link.
  • SSL Certificate installed and configured

Create the Rewrite Rule

Step 1. the IIS Manager

Open IIS Manager and, go to Start Page - [Server Name] - Sites - [Web Site Name]

Step 2. The {Features View} pane

From the {Features View} pane, open URL Rewrite module.

Step 3. The action pane

From the right on Action pane, click [Add Rules...] - Blank rule

Step 4. The inbound rule

At this point, we create the Inbound Rule, as the below image shows.

Step 5. Add a condition

Next, we must Add a Condition, like the one in the next image.

 Condition Input {HTTPS}  Add a condition stating that {HTTPS} is OFF 
 Pattern ^OFF$ This pattern ensures that the rule executes ONLY when the request arrives, and will not execute infinitely.

Step 6. Set the action properties

In the final step, we configure the Action, on Action Properties we add the value :[https://{HTTP_HOST}/{R:1}], select Redirect type: Permanent (301) and click Apply.

Conclusion

In this article, we read how we can redirect HTTP traffic to HTTPS using IIS URL Rewrite module.