Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Azure Front Door provides support for URL rewrite, enabling you to modify the request path that is being routed to your origin. This powerful feature allows you to define conditions that determine when the URL or specified headers should be rewritten. These conditions are based on the information present in the request and response.
By using URL rewrite, you have the ability to redirect your end users to different origins based on factors such as their device type or the type of file they're requesting. The URL rewrite action can be easily configured within the rule set, providing you with fine-grained control over your routing behavior.
Source pattern
The source pattern represents the URL path in the initial request that you wish to replace. Currently, the source pattern utilizes a prefix-based matching approach. To match all URL paths, you can specify a forward slash (/) as the value for the source pattern.
In the context of a URL rewrite action, only the path after the patterns to match in the route configuration is taken into consideration for the source pattern. For instance, the rule set considers only /source-pattern as the source pattern to be rewritten if you have an incoming URL format of contoso.com/pattern-to-match/source-pattern. After the URL rewrite is applied, the outgoing URL format will be contoso.com/pattern-to-match/destination.
In cases where you need to remove the /pattern-to-match segment of the URL, you can set the origin path for the origin group in the route configuration to /.
Destination
The destination path represents the path that replaces the source pattern. For instance, if the request URL path is contoso.com/foo/1.jpg, and the source pattern is /foo/, specifying the destination as /bar/ results in the content being served from contoso.com/bar/1.jpg from the origin.
Preserve unmatched path
Preserve unmatched path allows you to control how the remaining path after the source pattern is handled. By setting preserve unmatched path to Yes, the remaining path is appended to the new path. On the other hand, setting it to No (default) will remove the remaining path after the source pattern.
Here's an example showcasing the behavior of preserve unmatched path:
| Preserve unmatched path | Source pattern | Destination | Incoming request | Content served from origin |
|---|---|---|---|---|
| Yes | / | /foo/ | contoso.com/sub/1.jpg | /foo/sub/1.jpg |
| Yes | /sub/ | /foo/ | contoso.com/sub/image/1.jpg | /foo/image/1.jpg |
| No | /sub/ | /foo/2.jpg | contoso.com/sub/image/1.jpg | /foo/2.jpg |
Next steps
- Learn how to create an Azure Front Door profile.
- Learn more about Azure Front Door rule set
- Learn about Azure Front Door routing architecture.