You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Yusuf Koer <ma...@koer.de> on 2008/09/18 11:48:01 UTC
[users@httpd] redirecting based on the browser locale
Hi,
I would like to redirect to the right community based on the browser locale.
If my browser is set to English locale, Apache should automatically
redirect to for example mysite.com/en. Is that possible and how would
the RewriteCond/RewriteRule look like?
Thanks
Yusuf
---------------------------------------------------------------------
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
Re: [users@httpd] redirecting based on the browser locale
Posted by Nick Kew <ni...@webthing.com>.
On 18 Sep 2008, at 10:48, Yusuf Koer wrote:
> Hi,
>
> I would like to redirect to the right community based on the
> browser locale.
> If my browser is set to English locale, Apache should automatically
> redirect to for example mysite.com/en.
That's called HTTP content negotiation. RTFM mod_negotiation and
multiviews
for how to use it. And change language in your browser prefs to see
it in action
at (for example) httpd.apache.org - I guess from your .de address you
might
speak german as well as english, for example.
--
Nick Kew
---------------------------------------------------------------------
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
Re: [users@httpd] redirecting based on the browser locale
Posted by André Warnier <aw...@ice-sa.com>.
Yusuf Koer wrote:
> Hi,
>
> I would like to redirect to the right community based on the browser
> locale.
> If my browser is set to English locale, Apache should automatically
> redirect to for example mysite.com/en. Is that possible and how would
> the RewriteCond/RewriteRule look like?
>
Rule # 1 : the server never knows anything for sure about the client.
Rule # 2 : the server does not know the browser locale, because that's a
setting that the user can change locally, and it does not tell the
server about it.
This being said, about the only way I can imagine where you could "kind
of" guess the browser locale, are the "Accept-Language" and
"Accept-Charset" HTTP headers that the browser *might* send with his
requests.
You can check those with SetEnvIf (mod_setenvif) or with RewriteCond
(mod_rewrite), and use them to do something.
If you are into perl, you could also write a mod_perl add-on
access-control module that would pretty much allow you to do whatever
you want.
To see which such headers are being exchanged, an easy way is with the
Firefox add-on "LiveHttpHeaders", which is a useful add-on in many
circumstances anyway.
Otherwise, there must exist some Apache add-on module that dumps the
request headers somewhere.
There is also something in Apache called "content negociation", which
you might want to look up in the on-line documentation. I don't really
know if it is applicable in this case, but it might in any case give you
some ideas of how to do this cleanly.
Hope this helps
André
---------------------------------------------------------------------
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