Tag Archives: country

Cloudflare – ban country with .htaccess

One of my clients asked me to BAN an specific country to one of his sites.
Since we have Cloudflare, this is how I made it…

On .htaccess I’v simply added the following lines – on the top of .htaccess -.

SetEnvIf CF-IPCountry IN BuzzOff=1
SetEnvIf CF-IPCountry PT BuzzOff=1
Order allow,deny
Allow from all
Deny from env=BuzzOff

But remember!
Domain/subdomain must have Cloudflare active on DNS settings…

Block Visitors by Country 

A client needs to get a certain country blocked with .htaccess – or redirected -.
I’m gonna let some links of the solutions here…

Blocking an entire country stops most traffic coming from their IP ranges. 
This method isn’t 100% because some countries have slightly overlapping IP ranges.



  • .htaccess


  • .htaccess
  • Linux IPtable
  • CIDR


  • Wordpres Plugin