SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2008
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to block specific countries from certain pages of my website?

    Hi,

    I want to know how to block specific countries from certain pages of my website. I want to block 4 countries or so from just my main page and another page. Can this be done cleanly? If so how?

    Note: I would like the other pages that I don't include to work

    Much thanks in advance!
    Last edited by signature; Dec 21, 2009 at 15:29. Reason: adding of information

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Yes. Obtain an ip to location database (free ones are available, with lower accuracy than the paid versions), and use that to identify where the visitor is. You can either put the access logic in the pages (through some server side code which uses the database), or at the web server level (through MaxMind's mod_geoip for Apache).

  3. #3
    SitePoint Enthusiast
    Join Date
    Jan 2008
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks but I don't have the knowledge to implement that technology, is there an easier way?

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,598
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    That is about as easy as it gets to be able to do that. Of course you also need to keep the list up to date as IPs are occasionally moved between countries. Also there is nothing to prevent someone in a banned country using a proxy server in a country that isn't banned to be able to bypass the block.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  5. #5
    SitePoint Enthusiast
    Join Date
    Jan 2008
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks again, I'll try to get it to work with help from provider.

  6. #6
    SitePoint Member
    Join Date
    Dec 2009
    Location
    Oklahoma
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I use htaccess to block out undesirable countries from accessing my website. Before you do something like this though I would consider the undesired impact that this could have for your legit visitors.

    Even if your target demographic is local, you might be blocking out some legit visitors who are using AOL as their ISP. AOL uses proxies and someone visiting your website might live in your town, but the IP address they are connecting from could be coming from Europe... or anywhere. Still, there is good reason, in my opinion, to block out certain countries altogether. I know many on here would disagree, but some countries just have too much "bad" traffic to be trusted anymore. Use Google to find out more, I am unable to post links yet!

  7. #7
    SitePoint Zealot
    Join Date
    Aug 2009
    Posts
    122
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, if you don't want to use mod_geoip (and maxmind geo database) this site will generate .htaccess file for you:

    http://www.blockacountry.com

  8. #8
    SitePoint Member linux7802's Avatar
    Join Date
    Dec 2009
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In that case you need to block specific countries ip range....You can found out ip's by using following URL find-ip-address .org/ip-country/

  9. #9
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Alan22 View Post
    Hi, if you don't want to use mod_geoip (and maxmind geo database) this site will generate .htaccess file for you:

    http://www.blockacountry.com
    It'd be helpful if there was information, any information, about the source and accuracy of their data. For all I know they randomly generate it.

  10. #10
    SitePoint Member
    Join Date
    Apr 2009
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think this one is more accurate:

    http://www.ip2location.com/blockvisitorsbycountry.aspx

    At least IP2Location databases are updated every month.

  11. #11
    Non-Member thewebhostingdir's Avatar
    Join Date
    Oct 2005
    Posts
    703
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you are using WHM/cPanel then it is easy to block entire contry IP ranges from firewall like CSF. For more details how to block entire country in CSF visit following URL:

    http://www.vpsdiscussions.com/index.php/topic,87.0.html

  12. #12
    SitePoint Member
    Join Date
    May 2008
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have found that blocking countries is a very effective way to reduce spam as well. It is also a good idea to block the proxies that they use as well.

    There are several ways to implement country blocking but it is always a good idea to use a solution that prevents problematic users from coming back.
    Block Proxies, Bots, Scrapers, and more with BlockScript.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •