WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using WPML as a languages solution in my blog (in my case it's English and Spanish) I would like to know if there is a simple way of detecting where is a user coming from (which country.. I believe by IP) and redirect him immediately to either the Spanish site or the English site.
for instance: my site is www.website.com and the Spanish version is www.website.com/es I want people from lets say Argentina (and more latin countries) to see www.website.com/es and English spoken countries will see the regular English homepage as default.
Does someone have a solution? Thanks a lot Gil

share|improve this question

closed as off-topic by Mark Kaplun, Pieter Goosen, birgire, gmazzap, kaiser Sep 28 '14 at 11:09

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

html5demos.com/geo | stackoverflow.com/questions/2248404/about-geolocation-in-html-5 | I'm torn on whether to suggest closure. Just because WPML is involved, does this become on-topic? I feel it isn't, but I'm not sure enough to close vote. – Johannes Pille Nov 30 '12 at 7:09
@fischi gave the correct answer. Although this seems a good option, I would never use it on a site. Reason is that I like to give people the freedom instead of forcing a language on them. In your example all is fine, but take a non-Spanish speaker living in Spain or Latin America. That person most likely wants to see your site in English, not in Spanish, but as the IP address is from one of those countries, Spanish is forced upon him/her. – Piet Nov 30 '12 at 7:52
@Piet I like your reasoning there - but WPML offers the Redirect based on the Browser Language. I do not suppose that a lot of people use a Browser in a Language they don't speak. Also, you always have the possibility to switch back. – fischi Nov 30 '12 at 7:57
@fischi sorry, you are right, the redirect is on browser language, not on IP. – Piet Nov 30 '12 at 9:09
Maybe there is an htaccess solution or something.. I will also check with the WPML people. Thanks a lot @fischi – gil hamer Nov 30 '12 at 9:14

WPML offers this feature. You can set it in the Languages adminsection, at the option Browser Language Redirect.

share|improve this answer
Hi guys and thank you for your kind answers. @fischi - I found this option: Always redirect visitors based on browser language (redirect to home page if translations are missing) and checked it. It says that it goes by the browser's language and not country or IP. Do u think it's a good solution? what if a guy in a latin country has English version browser? will he see the English or the Spanish version? Thanks – gil hamer Nov 30 '12 at 9:05
@gilhamer yeah i think this is a good solution, as a visitor from a latin country does not certainly speak Spanish - the browser language gives you the best clue to the preferred language of the user. – fischi Nov 30 '12 at 9:54
+1 That is definitely the best solution. I am German and I live in Germany, but my OS and Browser language is English. I use google.com and not google.de. When on a new / friend's / other system and google.com redirects me to google.de it annoys the living crap out of me. Hence, I'd say, yes, best solution. | As an aside, if this is an inherent feature of WPML, I suppose it was a good decision not to vote to close. – Johannes Pille Nov 30 '12 at 18:35

I would add leaving a clear way of switching to other languages in case the visitor wants to (showing language "flags" maybe), don't know if WMPL includes this function

share|improve this answer
Not to be rude, but your answer isn't very good and not even answers the question, which was about automatic redirecting based on language, for the future, take a look at How to Answer – ialocin Oct 11 '13 at 16:48

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