Skip to content

Instantly share code, notes, and snippets.

@amirkhan81
Created January 18, 2021 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amirkhan81/89eb6783c57bbf9d0750a48302576e0b to your computer and use it in GitHub Desktop.
Save amirkhan81/89eb6783c57bbf9d0750a48302576e0b to your computer and use it in GitHub Desktop.
<rules>
<rule name="Remove www" stopProcessing="true">
<match url="(.*)" ignoreCase="true" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^www\.(.+)$" />
</conditions>
<action type="Redirect" url="http://{C:1}/{R:0}" appendQueryString="true" redirectType="Permanent" />
</rule>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<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>
<rule name="domainredirect" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^(www.)?currentdomain.com$" />
</conditions>
<action type="Redirect" url="https://newdomain.com/{R:0}" />
</rule>
</rules>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment