Azure CDN Microsoft Standard Rules Engine Rewrite URL for single-page-application
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
- Operator =
- Action:
URL rewrite
- Source Pattern =
/
- Destination =
/index.html
- Preserve unmatched path =
No
- Source Pattern =
This solution works for me. Make sure to purge your cdn cache before testing.
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
- source =
This will rewrite any URL without a dot in the trailing section to index.html.