0

Lets say I have domain http://domain.ru and a English visitor visits, it shows me English website based on IP sent him to /eng/ but If a Russian user went on send that person to /ru/

Instead of a User selecting an address I would like to filter only Russia and other countries, meaning that even if your in France you shall visit /eng/ but IF you are in Russia you visit /ru/

Any tips to do this? Or Recommendations?

Ruskie
  • 253
  • 2
  • 11
  • when any user, hit the site you have their IP, and can determine from IP from which country visitor belongs – Suleman Ahmad Nov 25 '13 at 13:11
  • possible duplicate of [Website that recognizes user's location/IP & changes lang. based on that](http://stackoverflow.com/questions/2039016/website-that-recognizes-users-location-ip-changes-lang-based-on-that) – Spudley Nov 25 '13 at 13:16

3 Answers3

1

You can get IP address of incoming request using $_SERVER['REMOTE_ADDR']. See this and this questions on how to map your IP address to a country.

There are several free SQL database with IP mapping here. They also have API.

Community
  • 1
  • 1
Nikolai Samteladze
  • 7,699
  • 6
  • 44
  • 70
0

IP addresses are not assigned in blocks to countries, so there is no easy way to do this. The best solution i've used is a third party database of IPs from a company called MaxMind - they have an open source version of the database at http://www.maxmind.com/en/opensource and there are many tutorials online for integrating this with a PHP application.

Chris Wheeler
  • 1,623
  • 1
  • 11
  • 18
0

You can user thrid party integration. There is a third party service, that detects country based upon user IP

Suleman Ahmad
  • 2,025
  • 4
  • 28
  • 43