Topic: Language Redirect

I am creating a multi-language (spanish, english) website. I wanted the website to automatically redirect to the correct language, if their in mexico then it would go to http://example.com/es and if they are in the usa, canada, or the uk then it would go to http://example.com/en . I have googled like crazy to try and do figure out something like this but I can't seem to find anything that I understand how to do. Is it possible to do this with php? I am fairly new to php so sorry if this is fairly basic. Thanks for your help in advance - Zane

Christianity, if false, is of no importance, and if true, of infinite importance. The only thing it cannot be is moderately important. ~ C.S Lewis

Re: Language Redirect

I have not done this before but I think it'd be better to detect their client settings as opposed to approaching it from a geographical aspect.  When the header gets passed back and forth there's a line:

Accept-Language: en-us,en;q=0.5


That is sent.  This is set via their language settings on their computer and browser.  There are plenty of Spanish speaking people in the US and I'd imagine plenty of English speaking people in Mexico; so you might be better served by using this information in the header.  Try searching for information PHP redirect Accept-Language or something.

Live with the wonder of a child, pray with your arms thrown open wide, love with a love that has no end; until I see you again ~ Mark Schultz

Re: Language Redirect

I found this which cost $50... http://www.ip2country.net/

This one appears to be free using the PHP PEAR library and Net:Geo http://articles.techrepublic.com.com/51 … 03179.html

The example using Net:Geo looks pretty simple to use too...

Daniel Marino | www.iamdanielmarino.com

Re: Language Redirect

I'd go with the Accept-Language header as well. It's also the least onerous option to implement:

http://www.thefutureoftheweb.com/blog/u … age-header

Ryan Heneise  |  Art of Mission  |  Now with extra-strong Donor Tools mojo

Re: Language Redirect

Also, remember that many people in Canada speak French.

Ryan Heneise  |  Art of Mission  |  Now with extra-strong Donor Tools mojo

Re: Language Redirect

Ok, first off thanks for everyone's help so far. I think I agree with ThePatch and ryenski about doing the Accept-Language header so I went to that link that ryenski supplied me but got totally lost as to where to put the code and modify for spanish etc. Could you guys point me in the correct direction. Again thanks so much for all your help so far.

Christianity, if false, is of no importance, and if true, of infinite importance. The only thing it cannot be is moderately important. ~ C.S Lewis