0
votes

I'm trying to set up a set of rules on my Azure Front door to redirect all requests to the root of a site to a set of language based subfolders based on the location match of the incoming request.

Doing the Geo-location part is fairly straightforward, but I'm not having much success limiting the requests to only the root of the site - or at least when I try to do so, my rules don't appear to match and I don't get the redirect I'm expecting.

Swiss Redirect Rule

I've tried setting the above conditions:

IF "Request Path" EQUAL "/"
AND IF "Remote address" "Geo Match" "Switzerland, CH"
THEN "Routing Configuration" "Redirect" "307"
                             Host: Preserve; 
                             Destination Path: Replace: "/de-ch/"

However I don't appear to be getting the redirect when requesting the root of the site from a browser based in Switzerland.

I can't find any actual examples for using the Rules Engine with either Path or matching, so I'm wondering if I should be using "Request URL" (and therefore I'll need to put the scheme and host in there, which is less than ideal as ruleset may be working with multiple front end hosts), or should what I'm doing work?

1
Looks like the important missing part of the documentation is that "Request Path" is rooted after the initial forward slash, so there is no way to use Request Path to match a request to the root of the application.Zhaph - Ben Duguid

1 Answers

1
votes

The "Request Path" match condition appears to match on the path after the initial /, for example given a request for:

https://www.example.com/folder/page.html

The following values are used in the match conditions:

Request Path:           folder/page.html
Request URL:            https://www.example.com/page.html
Request File Extension: html
Request Filename:       page.html

I therefore had to use the Request URL condition and limit my rules to the specific domain in the request to ensure that we were only matching the root requests.

I have not tried specifying an operator of Not Any yet, although that could also be a solution (we needed more that 25 rules, which is a further limitation, so ended up using a different solution).