Forum Discussion
Greg_33932
Nimbostratus
Feb 27, 2014IRule - combine 2 variables with an and && statment
Having issues with an irule. I'm no where an expert so please forgive my ignorance. Everything else works but the following statement (bolded is the new portion, rest is working):
if { ( $redirect_to...
IheartF5_45022
Nacreous
Mar 20, 2014I'm sorry - sometimes I answer without reading the whole thing, so I missed you were trying to access HTTP::status from HTTP_REQUEST. HTTP::status is a serverside attribute - no accessible from HTTP_REQUEST. I don't really understand what that whole 'if' statement is for BTW - I think you could just drop it altogether without changing the logic-flow through your iRule;-
when CLIENT_ACCEPTED {
set group "group_web_uri_Mobile"
set group_web_mobile_user_agents "group_mobile_user_agents"
}
when HTTP_REQUEST {
Set the user-agent field to all lower case so that the data group matches are not case sensitive
set user_agent [string tolower [HTTP::header User-Agent]]
set non_mobile_pool "qa.bbb.com"
set mobile_url "http://mobileqa.bbb.com"
set redirect_to_mobile "false"
set group $::group_uri_Mobile
Determine if the user agent (all lower case) is a member of the data group
if { [class match $user_agent contains $group_web_mobile_user_agents] } {
log local0. "Mobile - User-agent ($user_agent) is a member of the group_mobile_user-agents data group"
set redirect_to_mobile "true"
Check to see if it is an Android tablet. If it is, do not send it to the mobile site
if { ( $user_agent contains "android" ) && not( $user_agent contains "mobile" ) } {
log local0. "Mobile - User-agent ($user_agent) contains Android but is not Mobile"
set redirect_to_mobile "false"
}
} else {
log local0. "Mobile - User-agent ($user_agent) is NOT a member of the group_mobile_user-agents data group"
set redirect_to_mobile "false"
}
Now send the request to the appropriate destination based upon the value of the redirect_to_mobile variable
if { ( $redirect_to_mobile == "true" && [class match [string tolower [HTTP::uri]] starts_with $group] ) } {
HTTP::redirect "$mobile_url[HTTP::uri]"
} else {
pool $non_mobile_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