Skip to content

Instantly share code, notes, and snippets.

@alindgren
Created April 21, 2016 15:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alindgren/1d4585e75abde1e84595f4d0c25eeac5 to your computer and use it in GitHub Desktop.
Save alindgren/1d4585e75abde1e84595f4d0c25eeac5 to your computer and use it in GitHub Desktop.
HTTP to HTTPS redirect rule config transform
<?xml version="1.0" encoding="utf-8"?>
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.webServer xdt:Transform="InsertIfMissing">
<rewrite xdt:Transform="InsertIfMissing">
<rules xdt:Transform="InsertIfMissing">
<rule name="HTTP to HTTPS redirect" xdt:Locator="Match(name)" xdt:Transform="RemoveAll"/>
<rule name="HTTP to HTTPS redirect" stopProcessing="true" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
<add input="{HTTP_HOST}" pattern="localhost" negate="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment