July 1. 2011
6 Comments
- Posted in:
- IIS
For this small article, I assume that you have an Asp.Net web application running on IIS and that you have setup your SSL certificate. So navigating to https://www.yoursite.com works. This blog post will explain how to redirect all http traffic to https in several easy steps.
1. Get the Web Platform Installer (it’s free!) from Microsoft http://www.microsoft.com/downloads/en/details.aspx?FamilyID=32b0dfe5-f139-4e1c-b412-3da39f50bbf9
2. After you have opened the WebPI (Web Platform Installer) search for: Rewrite
3. Install the component! [more]
4. Open your web.config (I used notepad++ )
5. Merge this into your web.config:
<configuration> <system.webServer> <rewrite> <rules> <rule name="Force HTTPS" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" pattern="off" ignoreCase="true" /> </conditions> <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" /> </rule> </rules> </rewrite> </system.webServer> </configuration>
And your done, when you hit save. The IIS will restart if the web.config is modified, so the new rule is now enabled!