Last active
October 23, 2018 14:53
-
-
Save harvzor/5a4ecf3191d7fca8edf67f1b841d9c25 to your computer and use it in GitHub Desktop.
Rewrites!
This file contains 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"?> | |
<configuration> | |
<system.webServer> | |
<!-- Install URL Rewrite 2.0: https://www.iis.net/downloads/microsoft/url-rewrite --> | |
<rewrite> | |
<!-- http://stackoverflow.com/questions/35047484/iis-redirect-with-cache-response-header/35279811#35279811 --> | |
<outboundRules> | |
<rule name="Require clients to revalidationpermanent redirects"> | |
<match serverVariable="RESPONSE_Cache_Control" pattern=".*" /> | |
<conditions> | |
<add input="{RESPONSE_STATUS}" pattern="301" /> | |
</conditions> | |
<action type="Rewrite" value="public, must-revalidate, max-age=0"/> | |
</rule> | |
</outboundRules> | |
<rules> | |
<!-- If you have a sitemap located at domain.com/sitemap, this ensures that /sitemap.xml will render that page! --> | |
<rule name="Sitemap." stopProcessing="true"> | |
<match url="^sitemap.xml$" /> | |
<action type="Rewrite" url="sitemap" /> | |
</rule> | |
<!-- Redirect rule to force all URLs to lowercase --> | |
<!-- http://www.wiliam.com.au/wiliam-blog/iis-url-redirects-to-lowercase-and-umbraco-cms --> | |
<rule name="LowerCaseRule" stopProcessing="true"> | |
<match url="[A-Z]" ignoreCase="false" /> | |
<action type="Redirect" url="{ToLower:{URL}}" /> | |
<conditions> | |
<add input="{REQUEST_URI}" pattern="^.*/umbraco" negate="true" /> | |
<add input="{REQUEST_URI}" pattern="^.*/install" negate="true" /> | |
</conditions> | |
</rule> | |
<rule name="Add www." patternSyntax="Wildcard" stopProcessing="true"> | |
<match url="*" /> | |
<conditions> | |
<add input="{HTTP_HOST}" pattern="www.domain.com" negate="true" /> | |
</conditions> | |
<action type="Redirect" url="http://www.domain.com/{R:1}" /> | |
</rule> | |
<!-- | |
<rule name="Remove WWW" enabled="true" stopProcessing="true"> | |
<match url="(.*)" /> | |
<conditions> | |
<add input="{HTTP_HOST}" pattern="^(www\.)(domain\.com)" /> | |
</conditions> | |
<action type="Redirect" url="http://{C:2}/{R:1}" /> | |
</rule> | |
--> | |
<!-- | |
<rule name="Redirect to http" enabled="true" stopProcessing="true"> | |
<match url="(.*)" /> | |
<conditions> | |
<add input="{HTTPS}" pattern="on" /> | |
</conditions> | |
<action type="Redirect" url="http://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" /> | |
</rule> | |
--> | |
<!-- | |
<rule name="Redirect to https" enabled="true" stopProcessing="true"> | |
<match url="(.*)" /> | |
<conditions> | |
<add input="{HTTPS}" pattern="off" /> | |
</conditions> | |
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" /> | |
</rule> | |
--> | |
<!-- | |
<rule name="Add trailing slash redirect." stopProcessing="true"> | |
<match url="^[0-9a-z\-\/]+[^\/]$" /> | |
<conditions> | |
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> | |
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> | |
<add input="{REQUEST_URI}" pattern="^.*/umbraco" negate="true" /> | |
<add input="{REQUEST_URI}" pattern="^.*/install" negate="true" /> | |
</conditions> | |
<action type="Redirect" url="{R:0}/" /> | |
</rule> | |
--> | |
<rule name="Remove trailing slash." stopProcessing="true"> | |
<match url="^(.*)/$" /> | |
<conditions> | |
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> | |
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> | |
<add input="{REQUEST_URI}" pattern="^.*/umbraco" negate="true" /> | |
<add input="{REQUEST_URI}" pattern="^.*/install" negate="true" /> | |
</conditions> | |
<action type="Redirect" redirectType="Permanent" url="{R:1}" /> | |
</rule> | |
<rule name="Remove PHP redirect." stopProcessing="true"> | |
<match url="^(.*?)\.(?:php)$" /> | |
<action type="Redirect" url="{R:1}" /> | |
</rule> | |
</rules> | |
</rewrite> | |
</system.webServer> | |
</configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment