Skip to content

Commit c3cb75d

Browse files
Merge pull request #274943 from duongau/afdsvariable
Azure Front Door - Add offset variable to server variable
2 parents a7a075d + 959486d commit c3cb75d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

articles/frontdoor/rule-set-server-variables.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,21 @@ When you work with Rule Set actions, specify server variables by using the follo
5252
* Zero lengths: `{var:0:0}` = null, `{var:4:0}` = null
5353
* Offsets within range and lengths out of range: `{var:0:100}` = `AppId=01f592979c584d0f9d679db3e66a3e5e`, `{var:5:100}` = `=01f592979c584d0f9d679db3e66a3e5e`, `{var:0:-48}` = null, `{var:4:-48}` = null
5454
* `{url_path:seg#}`: Allow users to capture and use the desired URL path segment in URL Redirect, URL Rewrite, or any meaningful action. User can also capture multiple segments by using the same style as substring capture `{url_path:seg1:3}`. For example, for a source pattern `/id/12345/default` and a URL rewrite Destination `/{url_path:1}/home`, the expected URL path after rewrite is `/12345/home`. for a multiple-segment capture, when the source pattern is `/id/12345/default/location/test`, a URL rewrite destination `/{url_path:seg1:3}/home` results in `/12345/default/location/home`. Segment capture includes the location path, so if route is `/match/*`, segment 0 will be match.
55+
56+
Offset corresponds to the index of the start segment, and length refers to how many segments to capture, including the one at index = offset.
57+
58+
Assuming offset and length are positive, the following logic applies:
59+
* If length isn't included, capture the segment at index = offset.
60+
* When length is included, capture segments from index = offset up till index = offset + length.
61+
62+
The following special cases are also handled:
63+
* If offset is negative, count backwards from end of the path to get the starting segment.
64+
* If offset is a negative value greater than or equal to the number of segments, set to 0.
65+
* If offset is greater than the number of segments, the result is empty.
66+
* If length is 0, the return the single segment specified by offset
67+
* If length is negative, treat it as a second offset and calculate backwards from the end of the path. If the value is less than offset, it results in an empty string.
68+
* If length is greater than the number of segments, return what remains in the path.
69+
5570
* `{url_path.tolower}`/`{url_path.toupper}`: Convert the URL path to lowercase or uppercase. For example, a destination `{url_path.tolower}` in URL rewrite/redirect for `/lowercase/ABcDXyZ/EXAMPLE` results in `/lowercase/abcdxyz/example`. A destination `{url_path.toupper}` in URL rewrite/redirect for `/ABcDXyZ/example` results in `/ABCDXYZ/EXAMPLE`.
5671

5772
## Supported rule set actions

0 commit comments

Comments
 (0)