How to Block Visitors / Traffic from a Specific Country
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.
Block Visitor or Traffic from specific Country or Countries
How to Block Visitors or Traffic from a Country?
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.
How to Block Visitors / Traffic from a Specific Country
- 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!
IMPORTANT: This blog welcomes Guest Bloggers, Writers to also contribute by writing Guest Posts and also Make Money!. Check out our Revenue Sharing Program
For Further Reading:
- Facebook Timeline introduced to all users
- Use What Do You Love (WDYL) to search in all Google Services at one go
- Hide Google+ Notification from Google Bar [ How-To ]
- How to Jailbreak iOS 5 Beta On Mac using Redsn0w 0.9.8b1 [GUIDE]
- How to Jailbreak iOS 4.3.3 Untethered With PwnageTool 4.3.3
- How to Jailbreak iOS 4.3.3 Untethered With Redsn0w 0.9.6rc15 on Windows & Mac
- Downgrade iOS 4.3.3 to iOS 4.3.2, 4.3.1, 4.2,1, 4.1 on iPhone 4, 3GS, iPod Touch 3G, 4G & iPad 2 [How-To] Guide
- How to Video / Voice Chat on Nexus S from Google Talk
|
2049 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: |
Posted under: How-To, TipsNTricks
Article by Nihar
Nihar has written 1269 articles .If you like this Post, you can follow NiharsWorld on Twitter.
Subscribe to NiharsWorld feed via RSS or EMAIL to receive instant updates.
NiharsWorld is a revenue sharing blog, Write for us and make money. Read here for more info




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
@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.
Several people have asked why a person would want to block a country from accessing a website – well, I want to do it because someone I personally know from the UK is stalking me. They stole information from my website and passed it off as their own – we call that plagiarism in the USA. They constantly go to my websites to find out what I’m up to and steal email addresses from people who have linked to my site and stir up crap all the time. This person travels to various locations within the UK and accesses my site as well as using their iPhone. This has forced me to block the entire country since IP addresses change. If I miss out a few clients from the UK, that’s fine and worth the peace of mind to not be concerned with what one person is plotting to do. Some people are just plain nuts and I can do without the drama. I hope this gives you at least one reason to block a country!
@Jayne, Yes you are right. There might be other cases where we may want to block a specific country.