Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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:

RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^IT$
RewriteRule ^(.*)$ http://it.domainanme.com/$1 [R=303,L]
share|improve this question
    
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 at 8:00
    
Duplicate. Answered here: webmasters.stackexchange.com/questions/59619/… –  paul May 25 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 at 19:22
    
Don't forget to approve the answer if you like it, thanks! –  JVerstry Aug 25 at 17:38

1 Answer 1

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.

share|improve this answer
    
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 at 21:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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