Thursday, September 30, 2010

How to block visitors or traffic from one or more country

If you have a website which is just relevant for few countries only and you don’t want any unwanted traffic from other countries or you are spammed or attacked regularly from visitors from any country and want to block traffic from that country then you can modify your .htaccess file and block users from those countries.

Lets use service of a sited named www.blockacountry.com

select one or more country from country list to block visitors

  • Now on next screen you can see set of command, copy it and paste it to your .htaccess file, in case if you don’t have it in ftp then kindly talk to your host or create one using notepad or another text editor. This code having set of IP from countries you selected and it simply reject visitors request from those countries.

Copy this generated code, paste it into .htaccess file and upload it to server

Upload that .htaccess file into root of your domain using a ftp client. Every time when a visitor request your site from server it look into .htaccess file and if IP address of that visitor fall with in range of all denied IPs of your .htaccess then it will simply deny visitor request.


No comments:

Post a Comment