Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure CDN Microsoft Standard Rules Engine Rewrite URL for single-page-application

We try to configure Azure CDN on Microsoft Standard pricing to allow us rewrite Url to route all application routing to ./index.html. How to setup rules engine to rewrite url but left all js file as it is? All examples in google show how to do this on premium pricing but we like to do this on Microsoft Standard it is possible?

like image 673
CrazyBaran Avatar asked Nov 18 '19 12:11

CrazyBaran


People also ask

How does Azure CDN improve the performance of Web applications?

Azure CDN allows you to compress files to improve file transfer speed and increase application performance by reducing a file's size. It helps you to reduce bandwidth costs and provide a responsive experience to users.

What is the benefit of the Azure CDN?

Content Delivery Network helps reduce latency and improve performance for high-bandwidth content by distributing user requests and serving content directly from edge servers. This brings the content closer to users and sends less traffic to the origin point, delivering superior online experiences.

How many CDN profile is possible per subscription in Azure?

The number of Azure Content Delivery Network profiles that can be created in an Azure subscription is 25.


2 Answers

I finally got a working answer from Microsoft Support on this. They said that the Microsoft CDN Rules Engine does not support URL file extension Not Any and instead I should check for the length of the file extension.

  • Condition: URL file extension
    • Operator = Not greater than
    • Extension = 0
    • Case Transform = No transform
  • Action: URL rewrite
    • Source Pattern = /
    • Destination = /index.html
    • Preserve unmatched path = No

This solution works for me. Make sure to purge your cdn cache before testing.

like image 146
seabass Avatar answered Sep 18 '22 06:09

seabass


If none of your page URLs contain a dot, you can set a rule as follows:

  • Condition: 'URL file extension' = Not Any (i.e. there is no extension)
  • Action: 'URL rewrite',
    • source = /
    • destination = index.html
    • Preserve umatched path = No

This will rewrite any URL without a dot in the trailing section to index.html.

like image 41
limos Avatar answered Sep 19 '22 06:09

limos