Hello, I hope you’re all well! We’re attempting to use Single Redirect Rules to do the following:
- Check for a hostname,
example.com
- Check for a specific country, e.g. UK
- Add a locale to the URL
We’ve currently been able to get the following to work:
When:
(http.host eq "example.com" and ip.geoip.country eq "GB" and http.request.uri.path eq "/" and not http.referer contains "en-")
Then: lower(concat("https://example.com", "en-", ip.geoip.country ))
This will successfully add “en-gb” to the URL and redirect the user to htttp://example.com/en-gb
My two questions are:
-
We’re using
not http.referer contains "en-"
to allow a user to switch locales via a UI toggle, i.e. if “en-” is a referrer, allow the user to switch toexample.com
. This works in Safari, but Chrome / Chromium based browsers don’t seem to pick up the referred correctly. Any ideas on potential alternatives? -
Whilst the above works for the root domain, we’ve not been able to find a way to maintain the URI path so that we can add a locale to all URLs, e.g.
example.com/pricing
→example.com/en-gb/pricing
, without resorting to using regex, which unfortunately is only available on Cloudflare Business and costs $200 a month (we’re on Pro…). Bulk redirects isn’t a suitable option as it would mean maintaining a list of all possible URLs
Thank you for your help!