IIS 7+ : Redirect HTTP to HTTPS

These days, Google forces you to enable HTTPS on your website. If you google it for IIS, you will find several Microsoft post like this : https://blogs.technet.microsoft.com/dawiese/2016/06/07/redirect-from-http-to-https-using-the-iis-url-rewrite-module/

But the solution gave is wrong, you need this rule with Rewrite Module:

<rule name="Redirect to http" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
 <match url="*" negate="false" />
 <conditions logicalGrouping="MatchAny">
 <add input="{HTTPS}" pattern="off" />
 </conditions>
 <action type="Redirect" url="https://{HTTP_HOST}{URL}" redirectType="Permanent" />
 </rule>

(The mistake on the MS blog post is to use REQUEST_URI, not adapted with every cases)

This entry was posted in Uncategorized. Bookmark the permalink.