• Blogging
  • Freebies
  • Freeware
  • How-To
  • Make Money Online
  • Mobile
  • Home >> How-To >> How to Block Visitors / Traffic from a Specific Country

    How to Block Visitors / Traffic from a Specific Country


    There are times when you don’t want the Visitors or Web 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

    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 .htaccess file. 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
    1924 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:





    25 Comments

    1. Atul says:

      Hi Nihar
      image is excellent Do Not Enter 🙂

    2. 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.

    3. 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.

    4. Webbielady says:

      But why should you block those countries? I mean, they are extra traffic and potential ad customers, right?

    5. Raju says:

      wonderful tip Nihar, might be useful sometime!!

    6. Steve Yu says:

      Nice web tool. But I think I gonna skip this cos I love traffic.

    7. Nice find man… This will really help – sometimes those spam comments crom cn domains really piss me off.

    8. 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 ! ? 😉

    9. Donace says:

      An interesting idea indeed; It is very useful for blocking ‘sub-blocks’ of IP adds that have high spammers in them. (or compromised servers).

    10. tom says:

      Beethink ip blocker blocks country ip addresses with ease. I did it by importing Apache’s .htaccess files and start blocking.

    11. hmmm its nice…but how can i add new ips to the list

    12. Jayne says:

      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!

    Leave a Reply

    page counter
    NiharsWorld on Twitter NiharsWorld on Facebook NiharsWorld RSS Feed