Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
<!-- Redirect to HTTPS -->
<rule name="HTTPS_AlwaysOn" patternSyntax="Wildcard" stopProcessing="false">
<match url="*" />
<serverVariables>
<set name="HTTPS" value="on" />
</serverVariables>
<action type="None" />
<conditions>
<add input="{HTTP_X_FORWARDED_PROTO}" pattern="https" />
</conditions>
</rule>
<!-- 301 Redirect -->
<rule name="Simple_301_Redirect" stopProcessing="true">
<match url="Control/Some/productID/(.*)"/>
<action type="Redirect" url="Catalog/Category/Product/{R:1}" redirectType="Permanent" />
</rule>
<!-- 301 Redirect that uses a rewrite map -->
<rules>
<rule name="Example_Rewrite" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{ExampleRedirects:{REQUEST_URI}}" pattern="(.+)" />
</conditions>
<action type="Redirect" url="{C:1}" appendQueryString="false" redirectType="Permanent" />
</rule>
</rules>
<rewriteMaps>
<rewriteMap name="ExampleRedirects">
<add key="/some/page_product_51.html" value="Catalog/Category/Product/51" />
<add key="/Home/Index" value="/" />
</rewriteMap>
</rewriteMaps>
<!-- Redirect Based on query string -->
<rule name="Example_Validate_Query_String" stopProcessing="true">
<match url="search$" />
<conditions>
<add input="{QUERY_STRING}" pattern="^query=value$" />
</conditions>
<action type="Redirect" url="/Results/{R:1}" appendQueryString="false" />
</rule>
<!-- Redirect 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.mydomain.net" />
</conditions>
<action type="Redirect" url="http://www.mydomain.com/home/index" />
</rule>
<rewriteMaps>
</rewriteMaps>
<system.webServer>
<rewrite>
<rules configSource="rewriteRules.config" />
<rewriteMaps configSource="rewriteMaps.config" />
</rewrite>
<!-- rest of your stuff -->
</system.webServer>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment