Geo IP redirect and whitelist my own IP address

Slightly different from normal geo redirect: I want to whitelist my IP address or be able to temporarily disable redirecting to a subdomain.

Full request: I would like to redirect people in a country to a subdomain such as But, as I work on the website in that country sometimes, I would like to whitelist or temporarily disable the redirect so that I can look at the website while I’m working on it.


You can use a transform rule followed by a page rule to do this. I had a post previously on this. Just modify the targeting in the Transform rule to exclude your own IP address.

Use an expression like this in your Transform rule, replacing the countries and your IP address as needed:
( in {"AF" "AX" "AL"} and not ip.src in {} and eq ""))

Rewrite like this:

The Transform Rule essentially prepends a secret to every request where the request came from a certain country, except when the request came from a particular IP address.

And then have a page rule like this to do the redirect:

That redirects all requests that contain your super-secret prefix, which should only be the requests you targeted with your Transform Rule.

1 Like

Thanks Michael, I’ll pass this on to the coder/developer. Is this still using Cloudfare workers? And since I’m not a developer, is there a way to disable these rules temporarily if I change my IP address?

No, this is using Transform and Page rules. I have not tested how this would interact with Workers.

Yes, there is an on/off switch on the Transform rule. You could also add your new IP to the rule.

Thanks Michael, in your opinion, is it better to use transform and page rules, or better to use cloud fare workers?
Thanks again :slight_smile: !!

It really depends. The transform/page rule solution is relatively simple and efficient, and does not incur additional costs.

Doing this with Workers involves a bit more technical skill, and depending on your traffic volumes, might involve some costs. But Workers is a very powerful platform for building applications.

Personally, I don’t like the country redirect. It is possible to serve the correct content to the user without the redirect (again using either a Transform rule or Worker to detect the variant you need to deliver). I see a general direction of travel towards sites using Workers to deliver the complete application, rather than just making minor changes between Edge and Origin.

Wow Michael, you’re really helpful, thank you. Am I able to hire you to help me implement this please?
Thank you so much,
With warmth

Sorry, free help via the Community only. Try it, and come back here if you need help.

1 Like

Thanks!! You mean you could help me code this if I’m not a coder? I have no idea how cloudfare works. Someone just set it up for me.

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