I’m doing my first htaccess steps and going nowhere…
I have a site in German and English and I want to redirect all non German-speaking users to the English version of the site.
Here is what I have:
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP:Accept-Language} (cs|da|el|en|es|et|fi|fr|ga|hr|hu|it|lt|lv|nl|no|pl|pt|ro|ru|sl|sr|sv) [NC]
RewriteRule ^$ http://www.some.de/index.cfm?language=EN [R,L]
Two questions:
I’m in Germany with a browser set to German and I’m still redirected to the Englisch version. Why is that?
Will this have to be done for all subsequent pages in case the user starts out on some lower level page? Do I have to make a rewrite rule for every page?
Accept-Language is a mish-mash of language locales and values. Your browser probably also submits a bunch of other lang/locale pairs that gets matched in your regex (e.g. something like
en-ca,en;q=0.8,en-us;q=0.6,de-de;q=0.4,de;q=0.2). What you could try doing is matching for not de:Not sure how you’ve got your pages setup, but you could try changing your rule to this:
So requests for
/gets redirected to/?language=EN, and/somepath/to/somepath/?language=EN, and/file.cfm?someparam=valueto/file.cfm?language=EN&someparam=value