Skip to content

Tag: .NET

Redirect to HTTPS – Using URL Rewrite

I needed to redirect a HTTP website to HTTPS. I thought it was part of IIS, and I think it was at some point. Maybe in IIS 7.0.

But here is the code to redirect to HTTPS. I grabbed it from here http://ruslany.net/2009/04/10-url-rewriting-tips-and-tricks/.

You will also need to install the URL Rewrite module located here: http://www.iis.net/download/urlrewrite.

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