Using a URL Rewrite in the Rule sets After Route is not working

JUNIOR CABEZAS RODRIGUEZ 0 Reputation points
2025-02-15T05:56:26.4166667+00:00

I have two APIs, the structure is almost the same, but they should go to different backend pool, So I create "Resources" and "Resources2" as Routes

Resources, pattern to match : "/app/api/resources" (origin "server1")

Resources2, pattern to match : "/app/api/resourcesv2" (origin "server2")

I want to rewrite them to the origin with the path "/api/resources" or "/api/resourcesv2" for Server1 and Server2, since I need to have the full path to identify the pattern to match, I'm no able to use the "Origin path" with "/", so yes or yes I need to leave the "Origin path" in blank.

So what I thought was to create a rule set after the routing, something like :

User's image

In order to keep the last part of the url path because I needed, now reading some information microsoft said that "URL redirect and URL rewrite with Azure Front Door Standard/Premium (Preview) | Microsoft Learn

Currently, source pattern uses a prefix-based match.

For URL rewrite source pattern, only the path after the route configuration “patterns to match” is considered."

Finally I do not know how to address this case, I need the full path to go one server or another and then I need to rewrite in order to take part of the path, but it is not possible because microsoft only use the path after the route configuration "patterns to match".

Some ideas ? Thanksss

Azure Front Door
Azure Front Door
An Azure service that provides a cloud content delivery network with threat protection.
756 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Rohith Vinnakota 2,735 Reputation points Microsoft Vendor
    2025-02-17T23:06:28.29+00:00

    @JUNIOR CABEZAS RODRIGUEZ

    Hi

    I understand that if the pattern to match /app/api/resources should go to server1, then similarly, the pattern to match /app/api/resourcesv2 should go to server2.

    You can achieve this by configuring two routes and two backend pools.

    In the first routing rule we have configure the patterns to match like this.

    User's image

    similar to the second rule also.

    User's image

    I did a lab on my end using the above scenario, and I was able to achieve this.

    I take the two app services

    App Service 2
    User's image

    App Service 2

    User's image

    And i create the two routes.

    Routing rule1
    In the origin path : /api/resources/

    User's image

    Routing rule2:
    In the origin path : /api/resourcesv2/

    User's image

    If a request comes from https://endpoint021d9dxa4fsazbhgza9.a03.azurefd.net/app/api/resources/welcome.html, it should go to App Service 1 backend.

    User's image

    Also, if the request comes from

    https://endpoint021-d9dxa4fsazbhgza9.a03.azurefd.net/app/api/resourcesv2/welcome.html, it should go to the App Service 2 backend.

    User's image

    see in logs:

    User's image

    User's image

    I hope this has been helpful!


    If above is unclear and/or you are unsure about something add a comment below.

    Your feedback is important so please take a moment to accept answers. If you still have questions, please let us know what is needed in the comments so the question can be answered. Thank you for helping to improve Microsoft Q&A!

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

    0 comments No comments

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.