Disable Country Level Redirect After Clicking Certain Links

Its easy enough to use a worker to redirect based on the country code header. How can you then stop the redirect and allow the user to click a link to go elsewhere on the website. Example:

User in Belgium visits example.com (wordpress site) and gets redirected to example.com/en-BE (a react app). On this app there is a link to Visit Full Site, which should take them to example.com or example.com/some-page/ - But the country redirect keeps redirecting them to /en-BE

Does it need to be stored in a cookie on first load and then change the value of that cookie after the user clicks a non /en-BE/ page?

Thanks for any advice!

You could use a cookie for this, and then read it via the Worker. Or alternatively a simple URL query parameter such as ?ignore_redirect=1, and then don’t do a redirect if that param is present.

With the URL param I would have to keep that across all subsequent pages otherwise they would then get redirected back based on their country again?

Something like that, yes. A cookie would probably be the better solution if you want to avoid that, which you could set via a Set-Cookie header and then read on subsequent requests via the Cookie header.

1 Like

Thanks so much, I will try the cookie solution!

1 Like