Skip to content

Instantly share code, notes, and snippets.

@MrAntix
Last active January 1, 2026 17:52
Show Gist options
  • Select an option

  • Save MrAntix/6156413 to your computer and use it in GitHub Desktop.

Select an option

Save MrAntix/6156413 to your computer and use it in GitHub Desktop.
Url rewrite to get rid of www. sub-domain, works on sub-sub-domains too
<?xml version="1.0" encoding="utf-8"?>
<configuration>
...
<system.webServer>
...
<rewrite>
...
<rules>
...
<rule name="Redirect from WWW" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.(.*)$" />
</conditions>
<action type="Redirect" url="https://{C:1}/{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