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.
750 questions
{count} votes

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.