Feb 3, 2011

Easily Block Visitors from a Country using HTACCESS

If you have a website, sometimes you would want to block visitors coming from a country. For example you are running a promotion for certain countries and you don’t want visitors from other country to see it.

I'm suspecting country other than europe and north america, give me a low CTR, and it is not good for the value of the ads that appear in my site. If you can access the .htaccess file in root for your web content, you're able to block any ip for certain country. There is one country give me the high hits but low impression, so I block it for a few week and monitor the pattern of earning.

There is several website can help you to do this, but I choose the best two

Block A Country is a free service that automatically generates a .htaccess with countries that you want to block. All you need to do is select the countries from the list and click the “Go” button. You will then need to create a .htaccess file at the root of your public html folder and paste the codes to that file. Do take note that the default code generated by Block A Country redirects the unwanted visitor to http://www.blockacountry.com/blocked.php

Country IP Blocks is similar to Block A Country but it allows you to choose CIDR (Classless Inter-Domain Routing), Netmask, IP Range, .htaccess deny, .htaccess allow, Decimal/CIDR, or Hex/CIDR. It will also tell you what’s the ISO code for the country, total networks and subnets in the list.