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.
http://www.domain.com –> https://www.domain.com
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=”(.*)” />
<conditions>
<add input=”{HTTPS}” pattern=”off” />
</conditions>
<action type=”Redirect” redirectType=”Found” url=”https://{HTTP_HOST}/{R:1}” />
</rule>
Option 2: Using the IIS Manager, follow these steps.
- Under sites, select the site that you want this rule to apply to
- 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)
- Select “Add Rule(s)…”
- Blank rule and name the rule whatever you want it to be
- In the Match URL section, under Pattern:, put in (.*)
- Go to the Conditions section, click Add
- Condition input: {HTTPS}
- Check if input string: Matches the Pattern
- Pattern: off
- put a check mark in Ignore Case, and click OK
- In the Action section, select “Redirect”
- Action Properties: https://{HTTP_HOST}/{R:1}
- put a check mark for Append query string
- Redirect type: Permanent (301)
- Hit Apply