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
Feb 27, 2014The only thing I can see immediately is that you did not have $lower_uri defined. Here is iRule reformatted using "class match" rather than matchclass (which has been deprecated).
when CLIENT_ACCEPTED {
set group "group_web_uri_dddMobile"
set group_web_mobile_user_agents "group_web_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 "www.ddd.com"
set mobile_url "http://m.ddd.com"
set redirect_to_mobile "false"
set group $::group_web_uri_dddMobile
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. "dddMobile - 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. "dddMobile - User-agent ($user_agent) contains Android but is not Mobile"
set redirect_to_mobile "false"
}
} else {
log local0. "dddMobile - 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