I have a website:
http://www.example.com with several different languages aka:
example.com/us/
example.com/uk/
example.com/de/
example.com/fr/
etc...
Based on your IP, using a GeoIP script, you are pointed towards the right language except for languages from the EU (except UK). Those are done based upon the browser language.
Recently we "removed" /us/ and using .htaccess we 301 it to http://www.example.com/ which works fine.
But after the 301 rewrite, the GeoIP script still checks for your browser language (because the script didn't rewrite you yet). If you for instance use a browser with the language set to German and you browse to http://www.example.com/us/ the following happends:
http://www.example.com/us/
301 to http://www.example.com/
302 to http://www.example.com/de/ (based upon the browser language).
Obviously this isn't something you want so I'm trying to "fix" it.
All though I'm lost on how to fix it. I looked into using HTTP_REFERER, but that isn't to be trusted (according to the PHP manual) + it doesn't seem to work in this instance. The HTTP_REFERER stays empty?
Two questions:
1) What's the cleanest rewrite to rewrite /us/?
RewriteRule ^us$ [NC,OR]
RewriteRule ^us/$ [NC,R=301,L]
Does that come close? Or is there a better way?
2) Does anybody know a way to check where the visitor came from (the 301 redirect) so I can make sure my script doesn't 302 the visitor after the 301?
Thanks in advance!
With kind regards,
George
[edited by: dreamcatcher at 12:54 pm (utc) on Jun 7, 2010]
[edit reason] Fixed typo with example.com [/edit]