peduarte peduarte - 3 years ago 163
PHP Question

Restrict website to access specific country



I am wondering if it's possible to make my website only available to a specific country.
So anyone who tries to visit the website outside the specific country, will not have access.

I was thinking of getting a php IP Geo Locator script and do a redirect if they IP address is from the country I decide.

How would you guys recommend it?

Thank you.

EDIT

This doesn't have to be 100% accurate. Just need the php code that will do what I need.
The country is Romania by the way. Thanks! :)

Answer Source

The answer depends on what you mean by "available to a specific country".

  1. What if an in-country computer has an IP address not on your list? That computer won't have access, but it's located in country.

  2. What if an out-of-country computer has an IP address on your list? That computer will have address, but it's not located in country.

  3. What if a router with an in-country IP address forwards requests from out-of-country? What if an in-country router is part of the TOR network?

  4. What if a citizen leaves the country and wants to get access to your in-country web site from another country? The citizen will have an IP address not your list and will be denied access.

Until you define "available to a specific country" your question cannot be answered.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download