GoldenAge
GoldenAge

Reputation: 3068

Create a redirect rule for Azure CDN in Verizon which adds /index.html to the end of URL

I created an Azure CDN under Verizon Premium Subscription in the Azure portal with an endpoint which points to my Azure Static Website URL. I want to create a redirect rule in Azure Verizon engine which adds /index.html to the end of URL if no extension is specified or the last sing of URL is not a / symbol. So far I tried to use (.+\/[^\.]\w+$) regex expression, you can see an example of how it works here

My first approach: 1st approach

In this case, if you type the URL https://blah.com/foo/bar in the web browser it doesn't change the URL however you are able to view some of the content of the existing file from https://blah.com/foo/bar/index.html but some of the links to resources are broken. Not sure why I'm not getting the 404 in this case but maybe its because that I set the Index document name to index.html in the Static Website panel in the Storage account panel in Azure. If I open the Network tab in the developer tools of Chrome I can see a lot of 404 responses e.g. 404 resources And its because the website tries to get resources from the https://blah.com/foo/ directory instead of https://blah.com/foo/bar/ So, for example, the loadcsh.js in fact is located under the https://blah.com/foo/bar/loadcsh.js but the website is searching for the file under the wrong directory https://blah.com/foo/loadcsh.js

My second approach enter image description here In this case, if you type the URL https://blah.com/foo/bar it makes a redirect to https://blah.com/foo/bar/foo/bar/index.html so the foo/bar/ is redundant here.

My third approach enter image description here In this case, if you type the URL https://blah.com/foo/bar it makes a redirect to https://blah.com/index.html

I have no idea how to apply the rule which makes a redirect from https://blah.com/foo/bar to https://blah.com/foo/bar/index.html and is generic for all such cases. Any ideas?? Cheers

Upvotes: 4

Views: 1574

Answers (1)

Fan Cpp
Fan Cpp

Reputation: 86

I think your Regex expression is ok. You can add the rule URL redirect, in the Source textbox you type your Regex expression (.+\/[^\.]\w+$) and in the Destination textbox add https://%{host}/$1/index.htm. Here I used the HTTP variable for Azure CDN which can be used in Verizon. You can read more about the variables here. In short words the %{host} returns a host name e.g. www.contoso.com

Please keep in mind all rule changes will require couple of hours propagation before it takes an effect on the CDN.

Upvotes: 2

Related Questions