Want to set up Country-Based Redirection, but can't get it to work

Hello guys,

I am trying to set up a country-based redirection of incoming traffic, but I cannot get it to work. I tried with Workers, Transform Rules and Redirect Rules. My favorite solution would be to use Redirect Rules and it kind of works, but there seems to be a constant redirection loop.

I would like to forward US customers to www.domain.com/us-en/index.html and EU customers to www.domain.com/de-de/index.html.

Any help would be greatly appreciated!

Redirect Rules is the way to do this.

For looping, you’ll need to put some loop prevention into the filtering, i.e. ‘Country equals Germany then redirect to example.com/de/123’ will work, but what will happen is the request will come to Cloudflare, match the rule, the client will be redirected to the new URL, which will come back to Cloudflare, match the rule again, ad infinitum (up to 50, anyway).

To solve this you’ll need to build out the filtering, i.e. ‘Country equals Germany and URI Path doesnt begin with de’.

2 Likes

Hi smarsh,

wow, it works flawlessly! Thank you so much, that was so helpful, thank you!!! :star_struck:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.