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 {
if {[HTTP::header User-Agent] contains "Mozilla"}
{pool default-pool} else {pool mobile-pool}
I was givin a list of known mobile user agents to look for but wouldn't it be easier to just look for the non mobile user agents?
Version 9.4 HF4
- Vaughn_96017
Nimbostratus
ok, my bad it should look like this; - Wil_Schultz_101
Nimbostratus
I use a variation of the followingwhen HTTP_REQUEST { if {([string tolower [HTTP::host]] contains "my.com")} { 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 } } switch -glob [HTTP::header Accept] { "*text/vnd.wap.wml*" { pool mobile_pool } } } }
- Vaughn_96017
Nimbostratus
Thanks wschultz, - Wil_Schultz_101
Nimbostratus
I can try to give a quick overview but there are folks here that know way more than I 😄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 } }
switch -glob [HTTP::header Accept] { "*text/vnd.wap.wml*" { pool mobile_pool } }
- JRahm
Admin
iRules use a subset (minus the I/O commands) of standard TCL, so the switch command, while used in irules, is fully documented (along with the other TCL commands supported by iRules) on the TCL reference manual: - Vaughn_96017
Nimbostratus
wschultz- - Vaughn_96017
Nimbostratus
This is what I was given to redirect as mobile devices; - Wil_Schultz_101
Nimbostratus
Wow, that's a fairly extensive list 🙂switch -glob [HTTP::header User-Agent] { "*BlackBerry*" - "*UP.Browser*" - "*(GUI)*" - "*AUDIOVOX*" - "*AU-MIC,*" - "*Alcatel*" - "*BlackBerry*" - "*BENQ*" { pool mobile_pool } }
if {!([string tolower [HTTP::host]] == "mobilebypass.my.com")} { switch -glob [HTTP::header User-Agent] { "*BlackBerry*" - "*UP.Browser*" - "*(GUI)*" - "*AUDIOVOX*" - "*AU-MIC,*" - "*Alcatel*" - "*BlackBerry*" - "*BENQ*" { pool mobile_pool } } }
- Deb_Allen_18Historic F5 AccountJust answered another post that reminded me of the tcl "return" command.
- Deb_Allen_18Historic F5 Account(edited above for clarity)
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