Forum Discussion
Puli
Mar 31, 2011Nimbostratus
iRule to detect browser language and re-direct
Am working an iRule to detect browser's language and re-direct to the appropriate help page.
For example
www.abc.com browser language is french send it to www.abc.com/fr/help
...
The_Bhattman
Mar 31, 2011Nimbostratus
Hi Puli,
You can pull this from the HTTP header fields.
Specifically HTTP header field called Accept-language header
Click Here to go to a link that discusses accept-language header
As for the code I suppose you can use a untested iRule scripts like the following
when HTTP_REQUEST {
if { [HTTP::header "Accepted-Language"] contains "fr" } {
HTTP::redirect http://www.abc.com/fr/help
}
}
or you can go switch command route if you have many different language pages.
when HTTP_REQUEST {
switch -glob [HTTP::header "Accepted-Language"] {
"*fr*" - { HTTP::redirect http://www.abc.com/fr/help }
"*en-us*" - { HTTP::redirect http://www.abc.com/fr/help }
default - { HTTP::redirect http://www.abc.com/help }
}
}
The tool that I normally use is the HTTPFox to quickly look at the language my browser is set to. Click Here to see view how you can switch languages on the browser level.
I hope this helps
Bhattman
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects