Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jbubriski/9744469 to your computer and use it in GitHub Desktop.
Save jbubriski/9744469 to your computer and use it in GitHub Desktop.
<rewrite>
<!-- Have a bunch of redirects? Put them in a separate file -->
<rules configSource="Rewrites.config" />
<rules>
<!-- Simple rewrite -->
<rule name="Simple redirect" stopProcessing="true">
<match url="^path/sub path/page\.aspx$" />
<action type="Rewrite" url="/newpath.aspx" />
</rule>
<!-- Simple redirect -->
<rule name="Simple redirect" stopProcessing="true">
<match url="^path/sub path/page\.aspx$" />
<action type="Redirect" url="/newpath.aspx" />
</rule>
<!-- Based on query string -->
<rule name="Based on query string" stopProcessing="true">
<match url="^path/sub path/page\.aspx$" />
<conditions>
<add input="{QUERY_STRING}" pattern="^parameter=value$" />
</conditions>
<action type="Redirect" url="/newpage.aspx" appendQueryString="false" />
</rule>
<!-- Based on host name -->
<rule name="Based on host name" stopProcessing="true">
<match url="^path/sub path/page\.aspx$" />
<conditions>
<add input="{HOST_NAME}" pattern="^(www)?wakefly\.net$" />
</conditions>
<action type="Redirect" url="http://www\.wakefly\.com/newpage.aspx" />
</rule>
<!-- Canonical redirect -->
<rule name="Canonical redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HOST_NAME}" pattern="^www\.wakefly\.com$" />
</conditions>
<action type="Redirect" url="http://www\.wakefly\.com/{R:1}" />
</rule>
<!-- Force HTTPS -->
<rule name="Force HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
   <add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
</rule>
<!-- Stop hot-links -->
<rule name="Stop hot-links">
<match url=".*\.(gif|jpg|png)$"/>
<conditions>
<add input="{HTTP_REFERER}" pattern="^$" negate="true" />
<add input="{HTTP_REFERER}" pattern="^http://wakefly\.com/.*$" negate="true" />
</conditions>
<action type="Rewrite" url="/images/troll_face.png" />
</rule>
</rules>
</rewrite>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment