Exclude Countries

Hey community,

I don’t want to show my entire site to specific countries. How can I set this up in Cloudflare?


You can use firewall rules to block traffic based on its country of origin.


Example that would block US & UK traffic to part of a website:


That’s awesome! Thanks!

Can I show one specific page to visitors also? I mean if people from Germany see any of my pages, show a specific page with a message?


1 Like

Also, what do I need to set, if I want to block the whole domain? So, that none of the sites with that domain can be seen?

The firewall rule, minus the URI Path check will block unwanted countries from accessing anything in that zone (domain). The URI path really isn’t necessary in the situation you described.

Not from that domain, as it’s completely blocked. I can only think of a pretty convoluted approach:

  1. Add a Transform Rule for a URL Rewrite: IF in the country list, then Rewrite the Path (static) to something unique.
  2. Add a Page Rule where IF it matches that path, then Forwarding URL to some other place.


Just to be sure. I can set it this way?

Send people from country X who visit any page of domain A to a specific page on domain B?

That’s doable with what you suggest above?


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

Hey! I was asking this before, but my threat is already closed…

I was asking how I can block specific countries. I learned that I can do this in the firewall settings.

User “sdayman” told me that I can use the “transformation rule” to redirect people from the countries I want to block and have a message there for them, by leading them to a different domain, but I can’t find this setting anywhere in that list of rules…


Hi Timo… I think I have seen you somewhere already :eyes: Don’t know where… any chances you are german?

@sdayman is correct. I can recommend the tutorial from @michael: Redirect from a page to anotherpage for specific country for free - #4 by michael

Have a look at it and report back.

Additionally to that, there are also other options:

  1. Workers: Using Cloudflare Workers to redirect users based on country
  2. App: Cloudflare App geo-redirect


Now I know, it was the good old Digitale Eliteboard :wink:

1 Like

Hey Martin, (I guess) :smiley:

yes I am German and I am a member there - so chances are that we met there once :slight_smile:

Thanks for the info. I’ll take a closer look tomorrow.


Hey again!

I created the rule now, and I redirect to a different page, but I still can see that page. Any idea why?


Probably because the redirect does not work or the rule does not match the URL you are testing against.
If you could provide us with the URL and the PageRule/TransformRule we can look into that.

Ok. Here’s my setup:

Thanks :slight_smile:

Please change the marked area:

(without the leading https://timodee.com/)


And please first turn on the proxy :orange: in your DNS section on your entry for timodee.com since it currently is on :grey:. Otherwise you can not use Cloudflare features on this DNS entry.


ok. Thanks,

If I change that, how will cloudflare know that it should redirect to timodee.com? I’m blocking countries for a different domain…

Also, what is the difference between those two DNS settings? Will everything work as usual after the change?

Just to clarify: I’m blocking countries for all sites of “domainA” and I want to redirect to one specific site of “domainB”. Both domains are managed with cloudflare…

Then you:

  1. must be the owner of the other domain
  2. implement the transform rules on the other domains Cloudflare setting, while the DNS entry you want to perform this on must be set to :orange:

For basic understanding on what a proxy does and what the :orange: status does mean I would recommend the docs.

Then please do it like this:


  1. set it to :orange:
  2. set up TransformRule to append sorry-content-is-not-available/
  3. set up PageRule to redirect domainA.tld/sorry-content-is-not-available/ to https://domainB.tld


nothing to do here since you redirect to this domain, not from this domain.

And this also works if I block the whole domainA?