Redirecting HTTP requests to HTTPS

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}" />

5 thoughts on “Redirecting HTTP requests to HTTPS

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.