Rewrite Rule – Force https

Issue:  You have a particular domain on a Windows server that you want to force the URL to rewrite to the SSL certificate that is installed.  ie. –>

Option 1:  If you know how to edit the web.config file, just paste the following text within your system.webserver tags:

<rule name=”forceHTTPS” stopProcessing=”true”>
<match url=”(.*)” />
<add input=”{HTTPS}” pattern=”off” />
<action type=”Redirect” redirectType=”Found” url=”https://{HTTP_HOST}/{R:1}” />

Option 2:  Using the IIS Manager, follow these steps.

  1. Under sites, select the site that you want this rule to apply to
  2. On the right pane, you will see URL Rewrite, double click it (if it’s not installed, then you have to install it as a feature [Windows 2008] or see my Windows 2012 article entitled:  URL Rewrite Module in Windows 2012, where is it? for instructions on how to enable it)
  3. Select “Add Rule(s)…”
  4. Blank rule and name the rule whatever you want it to be
  5. In the Match URL section, under Pattern:, put in (.*)
  6. Go to the Conditions section, click Add
  7. Condition input:  {HTTPS}
  8. Check if input string:  Matches the Pattern
  9. Pattern:  off
  10. put a check mark in Ignore Case, and click OK
  11. In the Action section, select “Redirect”
  12. Action Properties:  https://{HTTP_HOST}/{R:1}
  13. put a check mark for Append query string
  14. Redirect type:  Permanent (301)
  15. Hit Apply

Leave a Reply

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