Azure Front Door URL Rewriting for Dynamic Paths
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?