httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Admin <aamit.apa...@gmail.com>
Subject Re: [users@httpd] How to set prefer-language from a URL parameter without cookies?
Date Thu, 20 Aug 2009 09:54:25 GMT
Hi,

I Show you an example of access manual from browser ..... having different
language support


AliasMatch ^/manual(?:/(?:de|en|es|fr|ja|ko|pt-br|ru))?(/.*)?$
"/usr/local/apache2/manual$1"

<Directory "/usr/local/apache2/manual">
    Options Indexes
    AllowOverride None
    Order allow,deny
    Allow from all

    <Files *.html>
        SetHandler type-map
    </Files>

    SetEnvIf Request_URI ^/manual/(de|en|es|fr|ja|ko|pt-br|ru)/
prefer-language=$1
    RedirectMatch 301 ^/manual(?:/(de|en|es|fr|ja|ko|pt-br|ru)){2,}(/.*)?$
/manual/$1$2

    LanguagePriority en de es fr ja ko pt-br ru
    ForceLanguagePriority Prefer Fallback
</Directory>

It gives u an idea....

Amit
http://new-innovation.blogspot.com/








On Tue, Aug 18, 2009 at 2:37 PM, Victor Engmark <victor.engmark@gmail.com>wrote:

> 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@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Mime
View raw message