Skip to content

Instantly share code, notes, and snippets.

@kyranjamie
Last active December 13, 2015 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kyranjamie/4988916 to your computer and use it in GitHub Desktop.
Save kyranjamie/4988916 to your computer and use it in GitHub Desktop.
ASP.NET - Remove www prefix with 301 redirect to root domain.
<rewrite>
<rules>
<rule name="Remove WWW prefix" >
<match url="(.*)" ignoreCase="true" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.domainname\.co.uk" />
</conditions>
<action type="Redirect" url="http://domainname.co.uk/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment