Hi all,
I'm trying to do language auto-negotiation in .htaccess on version
2.0.63, and it mostly works (see code below). The only thing that
doesn't is the "env=prefer-language:%1" part, and I can't figure out
why. I tried asking at Stack Overflow
<http://stackoverflow.com/questions/1280220/how-to-use-setenv-with-a-url-parameter>,
but although the answers are good, none of them seem to work. The
manual <http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewriterule>
didn't mention any gotchas and Google didn't help, so this is the last
try before going back to a PHP hack.
# Available languages
AddLanguage en .en
AddLanguage fr .fr
AddLanguage no .no
# Priority (highest first)
LanguagePriority no en fr
# Fallback to specified language priority if the browser doesn't
supply any of the supported languages
ForceLanguagePriority Fallback
# Language auto-negotiation
Options +MultiViews
# Set cookie when setting language in URL
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} (?:^|&)language=(en|fr|no)
RewriteRule ^(.*)$ $1?
[cookie=language:%1:.aspaass.no:7200:/,env=prefer-language:%1,redirect=permanent]
# Disable caching if the cookie was set
RewriteCond %{HTTP_COOKIE} language=(.*)
RewriteRule .* - [env=cookie_language:%1]
<IfDefine cookie_language>
Header append Vary cookie
Header set Cache-Control "store, no-cache, must-revalidate,
post-check=0, pre-check=0"
</IfDefine>
# Set preferred language from cookie if it exists
SetEnvIf Cookie "language=(.+)" prefer-language=$1
--
Victor Engmark
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
" from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx