1

Many websites directs the user to specific subdomains or domains based on their location. For example, if a user based in the UK types yahoo.com, the user somehow redirected to uk.yahoo.com. If the user is based on another country, say Japan, the user is redirected to jp.yahoo.com (this is just an example).

My question is: How web servers identify the users' locations? Is this only base don the IP? Are there any other techniques?

2 Answers 2

1

From the research that I did on this years ago, I found that the only reliable method of country detection is through IP address. There are giant databases that list all of the IPs of various countries, though I found obtaining one of these databases to be very difficult at the time.

If you were able to get a database of all of the IP addresses in the UK, you could check for those IP addresses in PHP. This can be done with this PHP parameter:

$_SERVER['REMOTE_ADDR']

Update: Apparently MaxMind GeoIP has a database of country IPs that may work.

1

The identification is based on the IP of the visitor.

There are many IP lists out there that link the IP of the visitor to the country they are coming from.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.