Redirect url basic on country (dynamic url)

hi, how to make redirect to different dunamic url based on country using rules? , my case is
without redirection , https:// domain .com , and I want to redirect it to “https:// domain .com/in/” when accessing form specific country, and dynamic urls like "http://domain.com/page” should redirect to “domain.com/in/pages”. ive gone through a tutorial in YouTube , but after configuring this , its showing like domain.com/in/in/in/in
please help me to solve this.

Going to need more context here. What are you using here? Page Rules? Bulk Redirects? Transform Rules (i.e. rewrite, not redirect)?

1 Like

im using page rules and transform rules, I followed this tutorial " Using Cloudflare Rules to Redirect Some Countries - YouTube "
but im looking for any model that works the way inorder to force different website on different countries , nor static but dynamic redirect , if we open a specific page url from a country , and that should redirect to the same page of the second website which is available to the country

hi, please help me regarding this

Just so I understand; you have a master domain, example.com. You want:

  • Visitors from the UK to example.com to be redirected to example.co.uk,
  • Visitors from France to example.com to be redirected to example.fr,
  • Visitors from Germany to example.com to be redirected to example.de?

If so, you’re best option is to deploy a Cloudflare Worker: https://developers.cloudflare.com/workers/examples/country-code-redirect

2 Likes

[quote=“deepak.r, post:6, topic:346456, full:true”]

yes exactly, but also a dynamic URL like if a visiter views a URL example.com/pages/page1 from the UK should redirect to example.co.uk/pages/page1

@smarsh , I tried, but it only redirects to static url ,
I setup like
const countryMap = {
IN: ‘https://domain.in/in’,
EU: ‘https://domain.in/eu’,
};

and when I use url " https://domain.in/product " from india, it just redirected to " https://domain.in/in "
but what I exactly want is to redirect to" https://domain.in/in/product "