I have a multilanguage website. My project was to add the Geolocalization so base on the country that open the site to redirect in the specific url with the right language. The structure of the website is

www.domainname (main domain)
it.domainname (subdomains for the languages)
de.domainname (subdomains for the languages)

All works fine but today i realize that i have the following problem. When someone from Italy try to open the website will be redirect to it.domainname. BUT if he wants to click in Flag of Emglish site(which is the www.domain) redirected again to the it.domainname. If wants to open any other language of the site it's not has a problem.

My rule in .htaccess is the following:

RewriteRule ^(.*)$ http://it.domainanme.com/$1 [R=303,L]
  • Just to add, its recomnded against redirecting users on their perceived location as it causes issues such as this. Try removing the redirect and then giving users the option to choose their own language. – Max Apr 2 '14 at 8:00
  • Duplicate. Answered here: webmasters.stackexchange.com/questions/59619/… – paul May 25 '14 at 1:11
  • Detecting language via scripting is not 100% accurate. Whatever you do you need to setup some kind of manual override. – JakeGould Aug 17 '14 at 19:22
  • Don't forget to approve the answer if you like it, thanks! – Jérôme Verstrynge Aug 25 '14 at 17:38

A solution is to implement the redirect using javascript on the user side rather than a rule on the server. You could also check for user settings saved on his/her device.

  • What if the client's JavaScript is off? I'd of thought a serverside script would have been better however to set a cookie or session to change the users preference. Surely, they just shouldn't be using htaccess to do this – Liam Sorsby Sep 16 '14 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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