Secure Site: ASP.NET URL Rewrite Rule HTTP to HTTPS Redirect

<rule name=”HTTP to HTTPS redirect” stopProcessing=”true”>

<match url=”(.*)” />
<conditions>
<add input=”{HTTPS}” pattern=”off” ignoreCase=”true” />
</conditions>
<action type=”Redirect” redirectType=”Found” url=”https://{HTTP_HOST}/{R:1}” />
</rule>

[/codesyntax]

 

I was adding a new SSL certificate to one of the client’s website and now we wanted only https accessible and redirect user if he/she tries to access http://website.com

So, i thought of available options and from all of those he best is to add a rewrite rule and it will take care of redirection and we even don’t have to update the site navigation and other links. :)