Skip to content

Instantly share code, notes, and snippets.

@derekmurawsky
Last active December 28, 2015 19:58
Show Gist options
  • Save derekmurawsky/7553658 to your computer and use it in GitHub Desktop.
Save derekmurawsky/7553658 to your computer and use it in GitHub Desktop.
web.config file to redirect to HTTPS, and a subdirectory. Disables HTTPS redirect for remoting layer. Redirects WWW.domain.com to https://domain.com
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="Root Hit Redirect" enabled="false" stopProcessing="true">
<match url="^$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Redirect" url="/home/" />
</rule>
<rule name="Redirect www.domain.com to domain.com" patternSyntax="Wildcard" enabled="false" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{HTTP_HOST}" pattern="www.domain.com" />
</conditions>
<action type="Redirect" url="domain.com/{R:0}" />
</rule>
<rule name="Remoting Bypass" enabled="false" patternSyntax="Wildcard" stopProcessing="true">
<match url="*Remoting*" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="None" />
</rule>
<rule name="HTTP to HTTPS redirect" enabled="false" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Found" />
</rule>
</rules>
</rewrite>
</system.webServer>
</location>
</configuration>
@derekmurawsky
Copy link
Author

Switched all rules to disabled by default. Better for initial deployments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment