• 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:

                <rule name="Force HTTPS" stopProcessing="true">
                    <match url="(.*)" />
                        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
                    <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />


And your done, when you hit save. The IIS will restart if the web.config is modified, so the new rule is now enabled!

kick it on DotNetKicks.com Shout it

Pin on pinterest Plus on Googleplus Post on LinkedIn


Comment by DotNetKicks.com

Asp.Net switch site to SSL (https) the easy way

You've been kicked (a good thing) - Trackback from DotNetKicks.com

Comment by DotNetShoutout

Asp.Net switch site to SSL (https) the easy way

Thank you for submitting this cool story - Trackback from DotNetShoutout

Comment by syngu.com

Pingback from syngu.com

Asp.Net switch site to SSL (https) the easy way | ASP.NET and .NET | Syngu

Comment by Ryan

Great article, however I'm having issues making it redirect for mysite.com (without www.) Any idea how I can change this to work for both www and non-www. Thanks!

Comment by JP Hellemons

Hi Ryan, try:

<rule name="CanonicalHostNameRule1">
<match url="(.*)" />
<add input="{HTTP_HOST}" pattern="^www\.jphellemons\.nl$" negate="true" />
<action type="Redirect" url="http://www.jphellemons.nl/{R:1}" />

JP Hellemons
Comment by Samir

This rule doesn't include directories http://localhost/myapp/Test.aspx redirects to https:///localhost/Test.aspx
Please help, how to make it include directories?