Skip to content

Instantly share code, notes, and snippets.

@l0ll098
Created January 11, 2018 09:04
Show Gist options
  • Save l0ll098/6c884b0cd2fa9564b8ad80e3f5c5793e to your computer and use it in GitHub Desktop.
Save l0ll098/6c884b0cd2fa9564b8ad80e3f5c5793e to your computer and use it in GitHub Desktop.
Force HTTPS on Azure/IIS websites. This file will rewrite every HTTP request to HTTPS. Works on Azure & IIS
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to https" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTPS}" pattern="off" />
<add input="{HTTP_HOST}" pattern="localhost" negate="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment