Azure Front Door URL Rewriting for Dynamic Paths

Arthur(Xueli) Wang 20 Reputation points
2025-02-10T20:46:37.96+00:00

During the migration from Azure CDN to Azure Front Door, URL rewriting issues are being encountered. In Azure CDN, the pattern (.*) was used to replace matched content with a new address while preserving unmatched content and appending a SAS token. Now, with Azure Front Door, the requirement is to use {url_path:seg#} for matching.

The goal is to rewrite URLs, for example, changing /content/* to /media/pdf/*?<SAS token>. For fixed directories, a rule like /media/pdf/{url_path:seg1:2}?<sas token> works. However, for dynamic URL lengths, such as:

  • /content/1/2/3/4.pdf to /media/pdf/1/2/3/4.pdf?<sas token>
  • /content/1/2/3/4/5/6.pdf to /media/pdf/1/2/3/4/5/6.pdf?<sas token>

the current URL rewrite rules are not producing the desired results. What is the correct way to implement these rules in Azure Front Door?I have tried multiple URL rewrite rules, but they don't seem to work. Does anyone know how to write the rules?

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

1 answer

Sort by: Most helpful
  1. Sai Prasanna Sinde 6,645 Reputation points Microsoft External Staff Moderator
    2025-02-11T06:43:15.7933333+00:00

    Hi @Arthur(Xueli) Wang

    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to accept the answer.

    Issue: Azure Front Door URL Rewriting for Dynamic Paths

    Solution: It should be Source pattern / and Destination /{url_path:seg0:99}/<sas_token>, Preserve unmatched path: No


    If you have any other questions or are still running into more issues, please let us know in the comments below.

    Please remember to "Accept Answer", so that others in the community facing similar issues can easily find the solution.

    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.