Technology Information: Easily Block Visitors from a Country using HTACCESS

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. Other than that, many years ago when I was in the e-book selling business, there are two countries (I am not going to reveal) which has very high chargeback cases, meaning they buy with their credit card and then inform their credit card company that they did not authorize the charge. The credit card company will then reverse the charges, allowing the buyer to get the intangible product for free by cheating. No matter how much proof I provided to the company that charged the credit card, the buyer still gets the advantage of reversing the charges.

So my last resort was to block the whole country and sending them to a Forbidden page that says “You don’t have permission to access / on this server. Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request”. It did reduced the amount of chargebacks significantly and I didn’t notice any drops on the sales because the legitimate buyers comes from other countries.

To block a country using .htaccess, you must first need to know the IP address
range but Block A Country and Country IP Blocks simplifies all that.

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

[ Visit Block A Country ]


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.

[ Visit Country IP Blocks ]

Once in a while the forum will be disturbed by a person named Gurjeet Singh Komal from Meerut, Uttar Pradesh India. He was probably the biggest fan of this website but backfired and turned into the biggest enemy because he was banned for not following the forum rules even after several warnings. He’d sign up a new account and start creating new threads by posting nonsense. It’s definitely unfair to block India from this site just because of him. As far as I know, there are many nice people from there too! Moreover it is also easy to get around this country banning restriction by using web proxy.

0 comments:

Enter your mail address:
Template by - ADMIN | HiTechvnn Template