Password-Protection based on Region?

by 2 replies
3
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?
#programming #based #passwordprotection #region
  • 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.
    • [1] reply
    • 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
  • Banned
    [DELETED]
  • 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.

Next Topics on Trending Feed