htaccess redirection on language

This is a discussion on htaccess redirection on language within the Apache Web Server forums, part of the Web Server and Related Forums category; Hi, I'm using this .htaccess to redirect users based on browser language: RewriteEngine on RewriteCond %{HTTP:Accept-Language} (it) [...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-20-2007
Pipp
 
Posts: n/a
Default htaccess redirection on language

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 ?

  #2 (permalink)  
Old 01-20-2007
HansH
 
Posts: n/a
Default Re: htaccess redirection on language

"Pipp" <ddr2pw@yahoo.com> schreef in bericht
news:1169314719.318115.179180@51g2000cwl.googlegro ups.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/mod....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


  #3 (permalink)  
Old 01-21-2007
Pipp
 
Posts: n/a
Default Re: htaccess redirection on language


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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:56 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0