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 {
...
Wil_Schultz_101
Nimbostratus
Jun 28, 2007I can try to give a quick overview but there are folks here that know way more than I 😄
So to get started with iRules you should definitely check out the iRules homepage:
http://devcentral.f5.com/wiki/default.aspx/iRules.HomePage
To give you a quick rundown of this rule in particular, here is the flow:
While the transaction is in the HTTP_REQUEST state, as opposed to HTTP_RESPONSE or some other state. this rule will be run.
The 'if' statement will grab the HTTP::host and make it all lowercase for the comparison, so there is no difference between My.com, MY.com or my.com.
The switch will look at the User-Agent portion of the HTTP::header, you can use several options:
http://devcentral.f5.com/wiki/default.aspx/iRules/switch.html
Glob basically allows the use of some wildcards, so "*BlackBerry*" will match anything that contains "BlackBerry". So the following will look for UserAgents that match, and then use mobile_pool at the end.
switch -glob [HTTP::header User-Agent] {
"*BlackBerry*" -
"*Blackberry*" -
"*Java/1.4.1_02*" -
"*Blazer*" -
"*blazer*" -
"*palm*" -
"*Palm*" -
"*SMARTPHONE*" -
"*Smartphone*" -
"*smartphone*" -
"*Danger*" -
"*hiptop*" -
"*MOT-*" -
"*RAZR*" -
"*AUDIOVOX*" -
"*Symbian*" -
"*symbian*" -
"*NOKIA*" -
"*Nokia*" -
"*Sony Ericsson*" -
"*Samsung*" -
"*LG 8*" -
"*Alcatel 735i*" -
"*Nextel*" -
"*Windows CE*" -
"*NetFront*" {
pool mobile_pool
}
} If nothing above matches, we look for the Accept portion of the header, if it contains "*text/vnd.wap.wml*" then it will go to the mobile_pool
switch -glob [HTTP::header Accept] {
"*text/vnd.wap.wml*" {
pool mobile_pool
}
}If none of the above matches, it either follows the remaining rules or whatever is set in the profile, which could be a default pool.
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
