SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2005
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Block countries from website

    I would like to block a few countries from my website, I have been told that htaccess is the way to do it. Can anybody tell me how to do this and if I need to contact my host about doing it.
    Thank you

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    23,588
    Mentioned
    411 Post(s)
    Tagged
    6 Thread(s)
    It's not easy to block a whole nation, because each nation has a large range of IP addresses. Still, there are sites that keep records of these. Have a look at ip2nation.

  3. #3
    Life is not a malfunction gold trophysilver trophybronze trophy
    TechnoBear's Avatar
    Join Date
    Jun 2011
    Location
    Argyll, Scotland
    Posts
    5,315
    Mentioned
    213 Post(s)
    Tagged
    5 Thread(s)
    There was another thread on a similar subject recently: http://www.sitepoint.com/forums/show...bsite-in-China

    While I was looking for that, I found an older one which might also be helpful:http://www.sitepoint.com/forums/show...-of-my-website

  4. #4
    SitePoint Enthusiast
    Join Date
    Jun 2005
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Than you for that I will read the whole thread and it might clear things up for me.
    Thanks again
    Sandra

  5. #5
    SitePoint Enthusiast
    Join Date
    Jun 2005
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I contacted my web host and asked if there was anything in the current htaccess file I needed to keep and they fixed my problem for me. They have allowed only the countries I deal with access to my site, which is perfect.
    Thank you for your suggestions and thank you Digital Pacific for your great support.

  6. #6
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    23,588
    Mentioned
    411 Post(s)
    Tagged
    6 Thread(s)
    Cool, glad you found a solution. I didn't know hosts offered that service. Funnily enough, I just moved to the same host recently, so good to know.

  7. #7
    SitePoint Member alexschmidt's Avatar
    Join Date
    Nov 2011
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I dont know if you need another opinion as it seems your problem is solved but there are some tools that help you with controlling the visitors of your sites. You can choose which countries will have access to your website. I found the Traffic Gatekeeper of Rankvision.com to help me with this for the sites I own.

  8. #8
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,604
    Mentioned
    19 Post(s)
    Tagged
    2 Thread(s)
    alex,

    They're using JavaScript to block countries. IMHO, it's better to use the PHP script that Ralph and TechnoBear suggested as it's far more reliable (and, I believe, faster). OR you could download the country IP list and keep that in your own db (MUCH faster) so a quick check of your own db would be all that's required to select country codes and either block of allow.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


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
  •