Forum Discussion
Vaughn_96017
Nimbostratus
Jun 27, 2007Redirect based on user browser (mobile)
I am writing an iRule that states if the user is coming in via a mobile device to get redirected to a different pool. My question, here is what I have, is this correct?
when HTTP_REQUEST {
...
hoolio
Cirrostratus
May 05, 2009I assume the request you expect to be redirected but isn't being redirected is being made with a host header which matches *mobile*, but isn't a mobile user-agent. Here are a few modifications to your version. You could use the logging in this example to troubleshoot your version.
when HTTP_REQUEST {
log local0. "[IP::client_addr]:[TCP::client_port]: New request from [HTTP::header User-Agent]\
to [HTTP::host][HTTP::uri]"
if {([string tolower [HTTP::host]] contains "mobile")} {
switch -glob [string tolower [HTTP::header User-Agent]] {
"*blackberry*" -
"*java/1.4.1_02*" -
"*blazer*" -
"*palm*" -
"*smartphone*" -
"*danger*" -
"*hiptop*" -
"*mot-*" -
"*razr*" -
"*audiovox*" -
"*symbian*" -
"*nokia*" -
"*sony ericsson*" -
"*samsung*" -
"*lb 8*" -
"*alcatel 735i*" -
"*nextel*" -
"*windows ce*" -
"*netfront*" {
pool mobile_pool
log local0. "[IP::client_addr]:[TCP::client_port]: Matched Host and User-Agent checks"
}
default {
Request didn't match User-Agent check
HTTP::redirect "http://non_mobile_website.com"
log local0. "[IP::client_addr]:[TCP::client_port]: Request didn't match User-Agent check"
}
}
} else {
Request didn't match Host header check
HTTP::redirect "http://non_mobile_website.com"
log local0. "[IP::client_addr]:[TCP::client_port]: Request didn't match Host check"
}
}
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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