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...
nitass
Employee
Apr 24, 2014just a few of comments.
1) beginning in 9.4.4, $:: prefix is no longer needed to reference data group. data group is now cmp compatible.
set group_mobile_sites $::group_web_uri_bbbMobile
set group_web_mobile_user_agents $::group_web_mobile_user_agents
CMP Compatibility (Class / Data Group List References section)
https://devcentral.f5.com/wiki/iRules.cmpcompatibility.ashx2) string operator (eq) should be used when comparing string
Polymorphism - Making TCL operators work for you by Colin Walker
https://devcentral.f5.com/articles/polymorphism-making-tcl-operators-work-for-you.U1iIr1dhcdU3) is this condition checking correct? i think the last elseif won't be matched.
if { ( $redirect_to_mobile == "true" && [class match [string tolower [HTTP::uri]] starts_with $group_mobile_sites] ) } {
HTTP::redirect "$mobile_url[HTTP::uri]"
} elseif { ( $redirect_to_mobile == "true" && not [class match [string tolower [HTTP::uri]] starts_with $group_mobile_sites] ) } {
pool $non_mobile_pool
} elseif { ( $redirect_to_mobile == "true" ) } {
HTTP::redirect "$mobile_url[HTTP::uri]"
}
could it be something like this?
if { $redirect_to_mobile eq "true" } {
if { [class match [string tolower [HTTP::uri]] starts_with group_web_uri_bbbMobile] } {
HTTP::redirect "$mobile_url[HTTP::uri]"
} else {
pool $non_mobile_pool
}
}
hope this helps.
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