Skip to content

Instantly share code, notes, and snippets.

@danshearmur
Created May 27, 2011 09:28
Show Gist options
  • Save danshearmur/994931 to your computer and use it in GitHub Desktop.
Save danshearmur/994931 to your computer and use it in GitHub Desktop.
Redirect to correct domain in IIS
<!--
- Redirect to correct domain in IIS
- Useful if you have more than one domain
- for example: maindomain.com, maindomain.co.uk, www.maindomain.co.uk, testingdomain.dev
- inspired by https://github.com/paulirish/html5-boilerplate-server-configs/blob/master/web.config#L192
-->
<rewrite>
<rules>
<rule name="Correct Domain" stopProcessing="true">
<match url="^(.*)$" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(?!www\.maindomain\.com)(.*)$" />
</conditions>
<action type="Redirect" url="http://www.maindomain.com{PATH_INFO}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment