Password-Protection based on Region?

2 replies
Hi folks,

Is there a way to restrict access to your site so that users from a specific country have to type in a login/pass to access even the main page?

We're looking to ensure that traffic from the rest of the world remains unaffected; however, we'd like not to exclude this one country entirely (otherwise we'd just block by IP), but to allow only selected users from that country to visit it by punching in a password.

Is it possible? Preferrably through .htaccess?
#based #passwordprotection #region
  • Profile picture of the author mojojuju
    Yeah it's possible and .htaccess would be a straightforward way of doing it. Take a look at what you can do with MaxMind's excellent GeoIP API and .htaccess. Here's some examples of redirecting by country with .htaccess: MaxMind - GeoIP Apache API

    If you can't use mod_geoip for some reason, there's a PHP api from Maxmind that will assist you in detecting people of certain countries and then requiring them to login.
    Signature

    :)

    {{ DiscussionBoard.errors[1812086].message }}
    • Profile picture of the author Bruce Hearder
      You will not going to block everyone from that country.

      People will use proxies, or even Tor and come to your site looking like visitors from another country..

      So yes it can be done, but its not real effective.. It all depends on how dumb your visitors are..

      Bruce
      {{ DiscussionBoard.errors[1814856].message }}
  • Profile picture of the author Aaron Sustar
    If you really want to do this, I suggest you use a highly optimized ip2nation database. They also provide a few example code snippets, so you will basically just need to copy-paste this code to your website and that's it.
    {{ DiscussionBoard.errors[1823230].message }}

Trending Topics