Re: redirecting based on the browser locale

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux