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…

Leave a Reply

Your email address will not be published. Required fields are marked *

*