URL Rewrite HTTP to HTTPS redirection on IIS 7

There are few ways to enable HTTP to HTTP redirect on IIS websites. In this example I will use URL Rewrite method.

  • If your don’t already have it download and install IIS URL Rewrite extension.

 

 

  • Double click on URL Rewrite in IIS Manager, then click Add Rules > Blank Rule
  • Configure the rule:
    • Name: HTTP to HTTPS
    • Match URL
      • Requested URL: Matches the Pattern
      • Using: Wildcards
      • Pattern: *
      • Ignore case: Yes
    • Conditions
      • Input: {HTTPS} 
      • Type: Matches the Pattern
      • Pattern: off
    • Action
  • Click Apply

Rewrite rule is written to <rewrite> … </rewrite> section of web.config file that is saved in the website’s root folder. In the above example it would look like this:


<rewrite>
<rules>
<rule name="HTTP to HTTPS" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTPS}" pattern="off" /> </conditions> <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="false" />
</rule>
</rules>
</rewrite>

June 2017
IIS 7

Windows Server 2008R2


Comments

Leave a Reply

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