You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 15/umbraco-cms/reference/routing/iisrewriterules.md
+63-7Lines changed: 63 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -83,11 +83,20 @@ For more details and other examples, take a look at the [URL Rewriting Middlewar
83
83
84
84
## Examples of rewrite rules
85
85
86
-
* A great site showing 10 very handy IIS Rewrite rules: [URL rewriting tips and tricks](https://ruslany.net/2009/04/10-url-rewriting-tips-and-tricks/)
87
-
* Another site showing some handy examples of IIS Rewrite rules: [Some useful IIS rewrite rules](https://odetocode.com/blogs/scott/archive/2014/03/27/some-useful-iis-rewrite-rules.aspx)
88
-
* If you needed to a lot of static rewrites using rewrite maps: [Rule with rewrite map rule template](https://www.iis.net/learn/extensions/url-rewrite-module/rule-with-rewrite-map-rule-template)
86
+
Below are some handy IIS Rewrite Rules you can use in your projects:
89
87
90
-
For example, to always remove a trailing slash from the URL (make sure Umbraco doesn't add a trailing slash to all generated URLs by setting `AddTrailingSlash` to `false` in your [RequestHandler settings](../configuration/requesthandlersettings.md)):
88
+
***10 Handy IIS Rewrite Rules**
89
+
A great resource showcasing 10 practical IIS Rewrite rules: [URL rewriting tips and tricks](https://ruslany.net/2009/04/10-url-rewriting-tips-and-tricks/)
90
+
91
+
***Examples of IIS Rewrite Rules**
92
+
Another useful collection of IIS rewrite rule examples: [Some useful IIS rewrite rules](https://odetocode.com/blogs/scott/archive/2014/03/27/some-useful-iis-rewrite-rules.aspx)
93
+
94
+
***Static Rewrites Using Rewrite Maps**
95
+
If you need to handle a lot of static rewrites, consider using rewrite maps: [Rule with rewrite map rule template](https://www.iis.net/learn/extensions/url-rewrite-module/rule-with-rewrite-map-rule-template)
96
+
97
+
### Example: Remove a Trailing Slash
98
+
99
+
To remove a trailing slash from the URL (ensure Umbraco does not add a trailing slash by setting `AddTrailingSlash` to `false` in your [RequestHandler settings](../configuration/requesthandlersettings.md)):
@@ -101,7 +110,9 @@ For example, to always remove a trailing slash from the URL (make sure Umbraco d
101
110
</rule>
102
111
```
103
112
104
-
Another example would be to enforce HTTPS only on your site:
113
+
### Example: Enforce HTTPS
114
+
115
+
To ensure your site only runs on HTTPS:
105
116
106
117
```xml
107
118
<rulename="Redirect to HTTPS"stopProcessing="true">
@@ -114,7 +125,9 @@ Another example would be to enforce HTTPS only on your site:
114
125
</rule>
115
126
```
116
127
117
-
Another example would be to redirect from non-www to www (except for the Umbraco Cloud project hostname):
128
+
### Example: Redirect Non-www to www
129
+
130
+
To redirect traffic from non-www to www (excluding the Umbraco Cloud project hostname):
118
131
119
132
```xml
120
133
<rulename="Redirect to www prefix"stopProcessing="true">
@@ -128,6 +141,49 @@ Another example would be to redirect from non-www to www (except for the Umbraco
128
141
</rule>
129
142
```
130
143
144
+
### Example: Remove the .aspx Extension
145
+
146
+
If you want to redirect .aspx URLs to their extensionless counterparts, you can use the following rule. Make sure you also have a web.config file in the root of your site:
147
+
148
+
```xml
149
+
<configuration>
150
+
<system.webServer>
151
+
<rewrite>
152
+
<rules>
153
+
<!-- Redirect .aspx URLs to their extensionless counterparts -->
If you use **Umbraco Cloud** check the [Rewrite Rules](https://docs.umbraco.com/umbraco-cloud/set-up/project-settings/manage-hostnames/rewrites-on-cloud) article.
188
+
If you use **Umbraco Cloud**, check the [Rewrite Rules](https://docs.umbraco.com/umbraco-cloud/set-up/project-settings/manage-hostnames/rewrites-on-cloud) article.
0 commit comments