Require HTTPS on Azure

To force HTTPS on an Azure site that is configured to run HTTPS and HTTP add the following to your web.config file:

<?xml version=”1.0″ encoding=”utf-8″?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<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>
</rules>
</rewrite>
</system.webServer>
</configuration>

Leave a Reply

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