Rewrite rule conditions in Azure Application Gateway are not matching subpaths when using the RequestUri variable.

Dan West 0 Reputation points
2025-12-12T20:47:15.17+00:00

Description: I am configuring a rewrite rule in Azure Application Gateway that uses a condition on the RequestUri server variable.

  • When I set the condition to match RequestUri == /v2/10, requests to /v2/10 are correctly detected.
  • However, when I set the condition to match RequestUri == /v2/10/access requests to /v2/10/access are not detected, even though I expect them to match similarly to the above.
  • I attempted to use a regex pattern (^/v2/10(/.*)?$) to capture both /v2/10 and any subpaths, but the rule still does not trigger for /v2/10/access.
  • I suspect the issue may be related to how RequestUri is evaluated (e.g., inclusion of query strings or trailing slashes), but the behavior is inconsistent with my expectations.
  • Steps to Reproduce:
  1. Create a rewrite rule with condition:
    • Variable: RequestUri
      • Pattern: ^/v2/10(/.*)?$
      1. Send requests to:
  • /v2/10 → rule matches
  • /v2/10/access → rule does not match

Expected Behavior: The rule should match both /v2/10 and any subpaths under /v2/10.

Actual Behavior: Only the exact /v2/10 path matches; subpaths like /v2/10/access do not.

Troubleshooting Already Tried:

  • Tested with regex patterns (^/v2/10(/.*)?$, ^/v2/10.*$)
  • Verified case sensitivity and trailing slash handling
  • Confirmed rule is applied to RequestUri variable
  • Created two rules one for v2/10 and another for v2/10/access
Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
{count} votes

1 answer

Sort by: Most helpful
  1. Q&A Assist
    2025-12-12T20:47:26.9866667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    It seems that the issue you're experiencing with the Azure Application Gateway rewrite rule conditions not matching subpaths using the RequestUri variable may be related to how the Application Gateway evaluates the RequestUri and the specific regex patterns used.

    Here are a few points to consider:

    1. Regex Evaluation: The regex pattern you've used, ^/v2/10(/.*)?$, should theoretically match both /v2/10 and any subpaths like /v2/10/access. However, ensure that the regex is correctly interpreted by the Application Gateway. Sometimes, slight variations in regex syntax or escaping might lead to unexpected results.
    2. Trailing Slashes: If the requests might include trailing slashes (e.g., /v2/10/), consider modifying your regex to account for that. You could try a pattern like ^/v2/10(/.*)?/?$ to capture both cases.
    3. Case Sensitivity: Ensure that the case sensitivity settings are appropriate for your conditions. If the incoming requests have different casing, they may not match.
    4. Testing with Different Patterns: Since you've already tested with various regex patterns, ensure that the conditions are being applied correctly. You might want to simplify the regex temporarily to see if any matches occur at all, such as ^/v2/10 to confirm that the rule is being triggered.
    5. Application Gateway Configuration: Double-check that the rewrite rule is correctly associated with the listener and that there are no conflicting rules that might prevent the expected behavior.

    If you've already verified these aspects and the issue persists, it may be beneficial to review the Application Gateway logs or consult Azure support for further assistance.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.