Skip to content

Commit 2550e68

Browse files
authored
Update rewrite-http-headers-url.md
1 parent e991934 commit 2550e68

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

articles/application-gateway/rewrite-http-headers-url.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,25 +62,23 @@ A rewrite set is a collection of a Routing Rule, Condition and Action.
6262
1. URL Query String: The new value to which the query string must be rewritten to.
6363
1. Re-evaluate path map: Specify if the URL path map must be re-evaluated after rewrite. If kept unchecked, the original URL path will be used to match the path-pattern in the URL path map. If set to true, the URL path map will be re-evaluated to check the match with the rewritten path. Enabling this switch helps in routing the request to a different backend pool post rewrite.
6464

65-
DONE
66-
6765
## Pattern matching and Capturing
68-
Patten matching and capturing are supported under Condition and Action. Pattern matching and capturing under Action is supported only for a specific header.
66+
Patten matching and capturing are supported under Condition and Action (under Action, it is supported only for a specific header).
6967

7068
### Pattern matching
7169
Application Gateway uses regular expressions for pattern matching. You should use Regular Expression 2 (RE2) compatible expressions when writing your pattern matching syntax.
7270

7371
You can use pattern matching under both Condition and Action.
7472
1. **Condition**: This is used to match the values for a Header or Server Variable. To match a pattern under "Conditions" use the "pattern" property.
75-
1. **Action**: Pattern matching under Action Set is only available for Response header "Set-Cookie". To match a pattern for Set-Cookie under an action, use the "HeaderValueMatcher" property. If captured, its value can be used as {capt_header_value_matcher}. As there can be multiple Set-Cookie, a pattern matching here allows you to look for other additional conditions. Example: For certain versions of user-agent under Condition, rewrite the set-cookie named "cookie2" with max-age=3600 (one hour).
73+
1. **Action**: Pattern matching under Action Set is only available for Response header "Set-Cookie". To match a pattern for Set-Cookie under an action, use the "HeaderValueMatcher" property. If captured, its value can be used as {capt_header_value_matcher}. As there can be multiple Set-Cookie, a pattern matching here allows you to look for a specific cookie. Example: For a certain version of user-agent, you want to rewrite the set-cookie named "cookie2" with max-age=3600 (one hour). In this case, you can use
74+
* Condition - Type: Request header, Header name: user-agent, Pattern to match: *2.0
75+
* Action - Rewrite type: Response header, Action type: Set, Header name: Set-Cookie, Header Value Matcher: cookie2=(.*), Header value: cookie2={capt_header_value_matcher_1};Max-Age=3600
7676

7777
> [!Note]
7878
> If you are running an Application Gateway Web Application Firewall (WAF) with Core Rule Set 3.1 or earlier, you may run into issues when using Perl Compatible Regular Expressions (PCRE) while doing lookahead and lookbehind (negative or positive) assertions.
7979
8080
### Syntax for capturing
8181

82-
To capture a substring for later use, put parentheses around the subpattern that matches it in the condition regex definition. The first pair of parentheses stores its substring in 1, the second pair in 2, and so on. You may use as many parentheses as you like; Perl just keeps defining more numbered variables for you to represent these captured strings. Some examples from [ref]:
83-
8482
Patterns can also be used to capture a sub-string for later use. Put parentheses around a sub-pattern in the regex definition. The first pair of parentheses stores its substring in 1, the second pair in 2, and so on. You may use as many parentheses as you like; Perl just keeps defining more numbered variables for you to represent these captured strings. You can find some example in this [Perl programming guidance](https://docstore.mik.ua/orelly/perl/prog3/ch05_07.htm).
8583
* (\d)(\d) # Match two digits, capturing them into groups 1 and 2
8684
* (\d+) # Match one or more digits, capturing them all into group 1

0 commit comments

Comments
 (0)