Block Visitors by Country Using htaccess

Blocking visitors by country using htaccess (Firewall) can be useful in case your blog/website is experiencing high volume of attack from particular country. It can also be very useful in case your website is experiencing DDOS attack from particular country.

For the example, we have tried to block China to browse website.

Access your htaccess file from you Cpanel. Add the below code to your htaccess files and save it.

order allow,deny
allow from all
deny from
deny from
deny from

To block all the visitor from particular country you need to find IP range of that country which you can get from ip2location website.

Leave a Reply

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