How to set url path in application gateway rewrite url for all incoming requests

ahd 105 Reputation points
2025-01-15T21:08:17.9066667+00:00

I'm trying to to make use of application gateway requests to rewrite all the incoming requests, ex: https://mytest.com/api/v1/... to https://mytest.com/qa/api/v1... for path based requests.

I have a gateway rule, with path based url set to /qa/*

is it a good way to do it ?

User's imageUser's image

Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
1,122 questions
{count} votes

Accepted answer
  1. Silvia Wibowo 5,281 Reputation points Microsoft Employee
    2025-01-16T23:26:30.8933333+00:00

    Hi @ahd , I understand you're asking about pattern matching for Application Gateway rewrite rule. You want to rewrite the path with pattern "/api/anycharacterafterit" to "/qa/api/anycharacterafterit".

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

    I think this will achieve what you're trying to do:

    • If
      • Type of variable to check: Server variable
      • Server variable: uri_path
      • Operator: equal (=)
      • Pattern to match: /api/(.*)
    • Then
      • Rewrite type: URL
      • Action type: Set
      • Components: URL path
      • URL path value: /qa/api/{var_uri_path_1}

    For more information, see Pattern matching and capturing.

    Please accept an answer if correct. Original posters help the community find answers faster by identifying the correct answer. Here is how.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

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