Skip to content

Instantly share code, notes, and snippets.

@aruss
Last active July 6, 2017 08:57
Show Gist options
  • Save aruss/31ab74b7f03c6835c3356661e00aa9f1 to your computer and use it in GitHub Desktop.
Save aruss/31ab74b7f03c6835c3356661e00aa9f1 to your computer and use it in GitHub Desktop.
UR Rewrite rules
<rule name="Whitelist IPs" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{REMOTE_ADDR}" pattern="212.203.321.40" negate="true" />
<add input="{REMOTE_ADDR}" pattern="5.13.161.12" negate="true" />
</conditions>
<action type="AbortRequest" />
</rule>
<rule name="WWW to non WWW" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www[.](.+)" />
</conditions>
<action type="Redirect" url="http://{C:1}/{R:0}" redirectType="Permanent" />
</rule>
<rule name="Non WWW to WWW" stopProcessing="true">
<match url=".*" negate="false" />
<action type="Redirect" url="{C:1}://www.{HTTP_HOST}/{R:0}" />
<conditions trackAllCaptures="true">
<add input="{CACHE_URL}" pattern="^(.*)://" />
<add input="{HTTP_HOST}" pattern="^(?!www\.).*" />
</conditions>
</rule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment