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: articles/frontdoor/rules-engine-scenarios.md
+11-7Lines changed: 11 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -73,7 +73,7 @@ Managing redirects is critical for search engine optimization (SEO), user experi
73
73
}
74
74
```
75
75
76
-
- **Redirect based on fixed-length URL path segments:** You can redirect requests to different origins based on fixed-length URL path segment by capturing the URL segments using `{variable:offset:length}`. For more information about server variable format, see [Server variables](/azure/frontdoor/rule-set-server-variables#server-variable-format).
76
+
- **Redirect based on fixed-length URL path segments:** You can redirect requests to different origins based on fixed-length URL path segment by capturing the URL segments using `{variable:offset:length}`. For more information, see [Server variable format](/azure/frontdoor/rule-set-server-variables#server-variable-format).
77
77
78
78
For example, consider a scenario where the tenant ID is embedded in the URL segment and is always 6 characters long, such as: `https://api.contoso.com/{tenantId}/xyz`. To extract `{tenantId}` from the URL and decide the correct redirect to use in the format of `tenantId.backend.com/xyz`.
79
79
@@ -147,7 +147,7 @@ Managing redirects is critical for search engine optimization (SEO), user experi
147
147
148
148
- **Redirect based on part of the incoming hostname:** You can redirect requests to different origins by extracting part of the incoming hostname.
149
149
150
-
For example, you can capture `tenantName` from `https://[tenantName].poc.contoso.com/GB` to redirect the request to `s1.example.com/Buyer/Main?realm=[tenantName]&examplename=example1` using the offset and length in server variable in the format of `{hostname:0:-16}`. For more information, see [Server variable format](/azure/frontdoor/rule-set-server-variables#server-variable-format)
150
+
For example, you can capture `tenantName` from `https://[tenantName].poc.contoso.com/GB` to redirect the request to `s1.example.com/Buyer/Main?realm=[tenantName]&examplename=example1` using the offset and length in server variable in the format of `{hostname:0:-16}`. For more information, see [Server variable format](/azure/frontdoor/rule-set-server-variables#server-variable-format).
151
151
152
152
:::image type="content" source="./media/rules-engine-scenarios/redirect-incoming-hostname.png" alt-text="Screenshot that shows how to use incoming hostname to redirect URL." lightbox="./media/rules-engine-scenarios/redirect-incoming-hostname.png":::
153
153
@@ -291,14 +291,15 @@ For example, you can replace the response header `X-Azure-Backend-ID` with a bra
291
291
292
292
### Scenario 4: A/B testing (experimentation)
293
293
294
-
Splitting incoming traffic based on client port into two origin groups can be is useful in A/B testing, rolling deployments, or load balancing without complex backend logic.
294
+
Splitting incoming traffic into two origin groups can be is useful in A/B testing, rolling deployments, or load balancing without complex backend logic.
295
295
296
296
For example, you can split incoming traffic based on the client port number. A rule can match client ports that end in 1, 3, 5, 7, or 9 and forward those requests to an *experiment-origin-group*. All other traffic continues to the default origin group per route settings. The previous regex is just an example, You can explore and test your own expressions using tools like [regex101](https://regex101.com/).
297
297
298
-
299
298
> [!NOTE]
300
299
> Since client ports are random, this method typically results in an approximate 50/50 traffic split. However, the presence of any proxies or load balancers between clients and the Front Door might affect this assumption due to factors like connection reuse or source port rewriting. Use logs or metrics to validate the actual behavior in your environment.
301
300
301
+
:::image type="content" source="./media/rules-engine-scenarios/a-b-testing.png" alt-text="Screenshot that shows how to split incoming traffic into two origin groups." lightbox="./media/rules-engine-scenarios/a-b-testing.png":::
302
+
302
303
```json
303
304
{
304
305
"type": "Microsoft.Cdn/profiles/rulesets/rules",
@@ -346,8 +347,11 @@ For example, you can split incoming traffic based on the client port number. A r
346
347
347
348
### Scenario 5: Redirect with URL path modification and preserve capability
348
349
349
-
Users need to add new segments, remove some segments and preserve the rest of the URL path.
350
-
For example, if you want to redirect https://domain.com/seg0/seg1/seg2/seg3 to https://example.com/seg0/insert/seg2/seg3, i.e. replace URL path’s {seg1} with /insert/ and keep the rest of the URL as-is. In this scenario, AFD can achieve the desired redirect by combining values extracted from server variables (URL segments) and combining static string segment “/insert/”. The semantics used to indicate we keep from seg2…n is by indicating Int32.Max (2147483647) for URL segment’s length field. See this page for more details.
350
+
In some scenarios, you might need to add new segments or remove some segments while preserving the rest of the URL path.
351
+
352
+
For example, if you want to redirect `https://domain.com/seg0/seg1/seg2/seg3` to `https://example.com/seg0/insert/seg2/seg3`. In this scenario, you replace URL path’s `{seg1}` with `/insert/` while preserving the rest of the URL path. Azure Front Door achieves the desired redirect by combining values extracted from server variables (URL segments) and combining static string segment `/insert/`. You can use `Int32.Max (2147483647)` for URL segment’s length field to keep all segments from *seg2* to *segn*. For more information, see [Server variable format](/azure/frontdoor/rule-set-server-variables#server-variable-format).
353
+
354
+
:::image type="content" source="./media/rules-engine-scenarios/redirect-url-path-modification.png" alt-text="Screenshot that shows how to redirect with URL path modification while preserving part of the URL path." lightbox="./media/rules-engine-scenarios/redirect-url-path-modification.png":::
351
355
352
356
```json
353
357
{
@@ -380,7 +384,7 @@ For example, if you want to redirect https://domain.com/seg0/seg1/seg2/seg3 to h
380
384
### Scenario 6: Redirect by removing fixed parts of a URL path
381
385
382
386
A user needs to remove fixed segments of known size from a URL like, country code (us) or locale (en-us), and preserve the rest of the URL path.
383
-
For example, if you want to redirect https://domain.com/us/seg1/seg2/seg3/ to https://example.com/seg1/seg2/seg3/, i.e. remove country code /us/ and keep the rest of the URL path as-is. Use the {variable:offset} which includes the server variable after a specific offset, until the end of the variable. For more information see, https://learn.microsoft.com/en-us/azure/frontdoor/rule-set-server-variables#server-variable-format.
387
+
For example, if you want to redirect https://domain.com/us/seg1/seg2/seg3/ to https://example.com/seg1/seg2/seg3/, i.e. remove country code /us/ and keep the rest of the URL path as-is. Use the {variable:offset} which includes the server variable after a specific offset, until the end of the variable. For more information, see[Server variable format](/azure/frontdoor/rule-set-server-variables#server-variable-format).
0 commit comments