Apache Server configuration support - htaccess redirection on language

This is Interesting: Free IT Magazines  
Home > Archive > Apache Server configuration support > January 2007 > htaccess redirection on language





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author htaccess redirection on language
Pipp

2007-01-20, 1:18 pm

Hi, I'm using this .htaccess to redirect users based on browser
language:

RewriteEngine on
RewriteCond %{HTTP:Accept-Language} (it) [NC]
RewriteRule .* http://www.site.com/index-it.html [R,L]

all italian browsers are directed to index-it.html but they are trapped
on the home page,
because if the surfer click on a link (for example
http://www.site.com/documents/doc.html)
he is always sent to http://www.site.com/index-it.html.

In my intention all english and other languages traffic should flow to
the standard http://www.site.com/index.html
page.

Can someone help me with this code or with some suggestion ?

Davide Bianchi

2007-01-20, 1:18 pm

On 2007-01-20, Pipp <ddr2pw@yahoo.com> wrote:
> Hi, I'm using this .htaccess to redirect users based on browser
> language:


Browser-selection language is already done by Multiviews, why are
you reinventing the wheel (in a broken way)?
Just activate Multiviews and you're on.

Davide

--
"Harry very carefully read the manual - four times - because Snape would
cut off his breathing privs if he asked him a question that the manual
could answer..."
-- Jim quotes Harry Potter and the Book Of The BOFH
HansH

2007-01-20, 7:26 pm

"Pipp" <ddr2pw@yahoo.com> schreef in bericht
news:1169314719.318115.179180@51g2000cwl.googlegroups.com...
> all italian browsers are directed to index-it.html but they are trapped
> on the home page,
> because if the surfer click on a link (for example
> http://www.site.com/documents/doc.html)
> he is always sent to http://www.site.com/index-it.html.
>
> In my intention all english and other languages traffic should flow to
> the standard http://www.site.com/index.html
> page.
>
> Can someone help me with this code or with some suggestion ?

In general a browser will, often to my dislike, choose my native language
for me. I like to read documentation in the native language of the
author -provided I am able to understand it-.

Have a peak how apache -both their site and yours- is handling
multi-language documentation: a visitor's choice overrides the browser's
preferance.
http://httpd.apache.org/docs/2.2/mo...n.html#typemaps

At first sight I think it has good change of working in.htaccess too.

The configuration -name and path varies per redistribution- has a section
like
<Directory "/usr/share/doc/apache2-doc/manual/">
Options Indexes
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128

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

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

Each set of files ...
:/usr/share/doc/apache2-doc/manual$ ls -1
bind.html
bind.html.de
bind.html.en
bind.html.fr
bind.html.ja.euc-jp
bind.html.ko.euc-kr

.... has a mapping
:/usr/share/doc/apache2-doc/manual$cat bind.html
URI: bind.html.de
Content-Language: de
Content-type: text/html; charset=ISO-8859-1

URI: bind.html.en
Content-Language: en
Content-type: text/html; charset=ISO-8859-1

URI: bind.html.fr
Content-Language: fr
Content-type: text/html; charset=ISO-8859-1

URI: bind.html.ja.euc-jp
Content-Language: ja
Content-type: text/html; charset=EUC-JP

URI: bind.html.ko.euc-kr
Content-Language: ko
Content-type: text/html; charset=EUC-KR

-- EoF


HansH


Pipp

2007-01-21, 7:26 am


Davide Bianchi ha scritto:

> Browser-selection language is already done by Multiviews, why are
> you reinventing the wheel (in a broken way)?
> Just activate Multiviews and you're on.


I'm not reinventing the wheel, I'm discovering it

I'm not an apache expert, so, if someone as a direct example, tutorial,
please point me to it.

Thank you

Davide Bianchi

2007-01-21, 1:18 pm

On 2007-01-21, Pipp <ddr2pw@yahoo.com> wrote:
> I'm not an apache expert, so, if someone as a direct example, tutorial,
> please point me to it.


http://httpd.apache.org/docs/2.0/co...egotiation.html

Davide

--
Dogs crawl under fences... software crawls under Windows 95.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com