Page is a not externally linkable
- Code, Content, and Presentation
-- Apache Web Server
---- Redirect MSIE browse + ES and DE traffic


lucy24 - 10:23 pm on May 28, 2011 (gmt 0)


the above statement implies that English is NOT this person's primary language

:P

OK, so you say rude things about Spaniards and Germans on your default page ;) This is fine. But extracting a language out of the Accept header is going to be a little bit messy.

For first-choice languages it is not a problem, as you've already seen:

RewriteCond %{HTTP:Accept-Language} ^(de|es) [NC]

(note the added ^ before the language pair). Since you're only looking at the very beginning of the language header, it doesn't matter if it's de-something or es-something.

Taking it to a second choice is trickier. You need to exclude German, Spanish and (I assume) Swedish from the beginning of your search, and then proceed to the second language, if there is one.

Look again at the beginning of my own language header.

HTTP_ACCEPT_LANGUAGE=iu,en-US;q=0.9,en;q=0.8,nb;q=0.7,nn;q=0.6,de;q=0.5 ... et cetera

The very first language is in the standard [A-Za-z][A-Za-z] form. But no browser knows it, so www sites have to proceed to language #2, or rather language #0.9. This one's got a more complicated name, so you have to allow for
(-[A-Za-z][A-Za-z])?
(The [NC] will be useful later on, to accommodate visitors who use the CAPS LOCK too much, but I wouldn't rely on it here.)

I think this is what you want for the second choice.

RewriteCond %{HTTP:Accept-Language} ^!(de|es|se) [NC]
RewriteCond %{HTTP:Accept-Language} (de|es)(-[A-Za-z][A-Za-z])?;q=0\.9 [NC]

That's assuming the first number is always 0.9. If it isn't... Ugh.

Someone else will come along and tell you if it is safe to combine this with a SetEnvIf and %{ENV:blahblah} so you don't have to say the same thing five times in a row.

Oh, and I was serious about Page[1-4] going to New[1-4]. Not with those exact names, of course. But if you have a pattern like

/flottside : /flottark
/herrligside : /herrligark
/vidunderlegside : sorry, I'm making this up as I go along

et cetera, then you will be able to put everything into a single RewriteRule.


Thread source:: http://www.webmasterworld.com/apache/4318766.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com