Skip to content

Instantly share code, notes, and snippets.

@CharlesInteractive
Created February 14, 2024 17:52
Show Gist options
  • Save CharlesInteractive/a07b3a8fc89659c94ce65a082610c7f7 to your computer and use it in GitHub Desktop.
Save CharlesInteractive/a07b3a8fc89659c94ce65a082610c7f7 to your computer and use it in GitHub Desktop.
Umbraco IIS rewrite rules examples.
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
<add input="{HTTP_HOST}" pattern="localhost" negate="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
<rule name="Remove trailing slash" stopProcessing="true">
<match url="(.*)/$" />
<conditions>
<add input="{REQUEST_URI}" negate="true" pattern="^/umbraco" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="{R:1}" />
</rule>
<rule name="Ignore" stopProcessing="true">
<match url="^(?:umbraco/api|umbraco/surface|umbraco/formulate|app_plugins/formulate)/" />
<action type="None" />
</rule>
<rule name="Allowed IPs" stopProcessing="true">
<match url="^(?:app_plugins|config|umbraco)(?:/|$)" />
<conditions>
<add input="{REMOTE_ADDR}" negate="true" pattern="127.0.0.1|192.168.0.1" />
</conditions>
<action type="AbortRequest" />
</rule>
<rule name="Rewrite Rule">
<match url=".*" />
<conditions>
<add input="{StaticRewrites:{REQUEST_URI}}" pattern="(.+)" />
</conditions>
<action type="Rewrite" url="{C:1}" />
</rule>
<rule name="Redirects one link to another" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{REQUEST_URI}" pattern="/redirectfrom$" />
</conditions>
<action type="Redirect" url="/redirectto" appendQueryString="false" redirectType="Permanent" />
</rule>
</rules>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment