Last active
May 9, 2019 13:39
-
-
Save davidisnotnull/75f57bc0cefb8fbadc4382aa6282ff96 to your computer and use it in GitHub Desktop.
Example redirects and rewrite rules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<rewrite> | |
<rules> | |
<rule name="RedirectRule"> | |
<match url="^redirect-url/(.*)" ignoreCase="true" /> | |
<action type="Redirect" url="/test/my-actual-url/" redirectType="Permanent" /> | |
</rule> | |
<rule name="RewriteRule"> | |
<match url="^my-new-url/(.*)$" ignoreCase="true" /> | |
<action type="Rewrite" url="Location/On/Server/{R:1}" /> | |
</rule> | |
<rule name="HTTP to HTTPS Redirect" enabled="true" stopProcessing="true"> | |
<match url="(.*)" /> | |
<conditions logicalGrouping="MatchAny"> | |
<add input="{SERVER_PORT_SECURE}" pattern="^0$" /> | |
</conditions> | |
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" /> | |
</rule> | |
<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="Add trailing slash" stopProcessing="true"> | |
<match url="(.*[^/])$"/> | |
<conditions> | |
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/> | |
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/> | |
<add input="{REQUEST_FILENAME}" pattern="(.*?)\.js$" negate="true"/> | |
<add input="{REQUEST_FILENAME}" pattern="(.*?)\.css$" negate="true"/> | |
<add input="{REQUEST_URI}" pattern="^/umbraco" negate="true"/> | |
<add input="{REQUEST_URI}" pattern="^/bundles" negate="true"/> | |
<add input="{REQUEST_URI}" pattern="^/install" negate="true"/> | |
<add input="{REQUEST_URI}" pattern="^/media/" negate="true"/> | |
<add input="{REQUEST_URI}" pattern="^/Campaigns" negate="true"/> | |
<add input="{URL}" pattern="^..(axd|css|js|jpg|jpeg|png|gif|woff|woff2|eot|ttf|svg|pdf|txt|aspx)$" negate="true" ignoreCase="true"/> | |
<add input="{REQUEST_URI}" pattern="^/DependencyHandler" negate="true"/> | |
</conditions> | |
<action type="Redirect" url="{R:1}/"/> | |
</rule> | |
</rules> | |
</rewrite> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment