Redirecting HTTP requests to HTTPS

On February 10, 2012, in How-to, Technical, by Michael

Michael OssouA common question that is often asked is how to auto-magically redirect HTTP requests for your web sites to HTTPS. Simply put, if someone types “” how can you redirect that request to “”?

This post is the simple answer to that question. IIS’s URL rewrite module can help us accomplish this as well as other rewrite tasks. For a complete look at how URL Rewriting works, take a look at the following MSDN article on URL Rewrite. Then look at the following as an example of what to add to your web.config:

          <rule name="Redirect to HTTPS" stopProcessing="true">
            <match url="(.*)" />
              <add input="{HTTPS}" pattern="^OFF$" />
            <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
Tagged with:  

4 Responses to “Redirecting HTTP requests to HTTPS”

  1. […] a previous post we showed you how to force a normal HTTP call to HTTPS. Today we’ll show you how to redirect from root to […]

  2. qwest says:

    wouldnt connect with my credentials – does not work – wasted a lot of time – is their some secret

  3. […] this is your first time making these however changes, take a look at a previous blog post on the […]

  4. David North says:

    Thanks for such a clear, concise example!

Leave a Reply

iBlog by PageLines