There are times when you don’t want the Visitors or Traffic to your Website or Blog from a Specific Country.
What could be the reason for blocking a country or countries?
Your site may have data that you don’t want to expose to some countries or your site is getting lot of abuses from a country. There could be any other reason as well. In such cases the site owner or Blog owner would want to block the unwanted traffic from a country.
How to Block Visitors or Traffic from a Country?
Block Visitor or Traffic from specific Country or Countries
I found a website which provides free service. The name of the website is Block a country. The website basically generates the list of country ip addresses so that you could block the whole country. It works based on country ip addresses so that you can block a country
Lets say if i want to block all the visitors or Traffic from Guyana. Just do the below.
- Visit the site Block Country.
- You will find a list box containing all the countries. Select Guyana and click on “Block Now!” Button.
- It will generate the script containing list of Country IP Addresses and Country IP Address Ranges.
- You need to copy the whole generated text and paste that in your
.htaccessfile. The generated script blocks the traffic coming from the that country.
Make sure you backup .htaccess file before you make any changes.
Block Country generated the below script for Guyana Country
# Blocking script by http://blockcountry.com/
RewriteEngine On
RewriteCond %{REMOTE_ADDR} ^190.80.0.[0-18]
RewriteRule ^(.*)$ http://blockcountry.com/blocked.php [L,R]
# Blocking script by http://blockcountry.com/
.htaccess file is located in /www/, /httpdocs/ or /public_html/ directories. Now nobody from the specified country cannot access your website.
If you look at the above generated script, It has the code which is also redirecting the Blocked Traffic to http://www.blockcountry.com/blocked.php. You can change to any other website like below
RewriteRule ^(.*)$ http://www.somewebsite.com/ [L,R]
You can also remove that line if you don’t want to redirected the blocked visitor.
In this way, you can deny access to blog/website from specific countries.
Few days back i posted two posts which are related in a way to this post. Do check them if you haven’t checked it.
How to Block Visitors from specific IP using .htaccess hack
How to avoid Hotlinking of file and images using .htaccess hack
If you know any other way, Please share via comments. Hope you learned something from this post!
|
1921 readers are already subscribed to this blog! Why don't you be one of them? Subscribe to this blog via your favorite RSS feed reader or by entering your email address on the form below: |
You Should Also Check Out These Posts:
- How to Block Visitors from specific IP using .htaccess hack
- May 2009 Blog Traffic & Income statistics
- How To Geo-Target Ads based on visitors location
- June 2009 Blog Traffic & Income statistics
- How to avoid Hotlinking of file and images using .htaccess hack


Subscribe
Hi Nihar
image is excellent Do Not Enter
Atuls last blog post..Zoozoo: The New Brand Endorser For Vodafone
@Atul, yeah thanks.
Hi,
I did not know how to block a country, but only a specific IP address. I can see the cons and pros of blocking but one has to be very careful as it could cost you in the end. Blocking legitimate visitors can lead into them never returning to your site again.
George Serradinhos last blog post..Serradinho reaches 1000 Comments Milestone
@George, I know but there may be times when you want to block the whole country. I also can’t think of such instance.
But, it is there thats why i shared this.
Hi Nihar,
pls could you get a gravatar? You always comment on my site and I don’t see that you have one. You need one as it identifies you more easily.
Let me know when you have one.
If you are going to start a downloads page, then let me know. Maybe I can help. I’m using a WP plugin to handle mine and it keeps track of the number of downloads and I can put them into different categories.
George Serradinhos last blog post..Serradinho reaches 1000 Comments Milestone
@George, I will definitely this weekend. thanks for the showing the concern. I will definitely ask for help to setup the download page.
But why should you block those countries? I mean, they are extra traffic and potential ad customers, right?
Webbieladys last blog post..How Does Money Mule Scam Affect Us?
@Webbielady, You are right. but there may be a instance where you may want to block the whole country.
wonderful tip Nihar, might be useful sometime!!
Rajus last blog post..GZip Compression and Wordpress
@Raju,
Glad that you liked the tip.
Nice web tool. But I think I gonna skip this cos I love traffic.
@Steve Yu, Me too. It is just a tip that i am sharing.
Nice find man… This will really help – sometimes those spam comments crom cn domains really piss me off.
Ajith Edasserys last blog post..Make Money Online blogs – Top lists
@Ajith, You are right. it will be helpful
Hey nice picture BTW !
I always use to wonder things like this..
Are they (Orkut, Youtube and so on) using this kind of methods for banning access from other countries ! ?
S.Pradeep Kumars last blog post..Remove WWW From The Blog’s URL Automatically
@Pradeep,
No. that is different. the ISP’s of that country will block based on the URL and ip address of that websites.
An interesting idea indeed; It is very useful for blocking ’sub-blocks’ of IP adds that have high spammers in them. (or compromised servers).
Donaces last blog post..Parasite hosting
@Donace, you are right. we could do that if we get the sub-block ip’s
Nice tip Nihar
[...] How to Block Visitors / Traffic from a Specific Country [...]
Beethink ip blocker blocks country ip addresses with ease. I did it by importing Apache’s .htaccess files and start blocking.
@tom, Thanks for the tip.
hmmm its nice…but how can i add new ips to the list
@admin tekshek, Not sure. I guess it provides most of the country specific ips.