Forum Discussion
Jeff_Morrison_4
Dec 05, 2007Nimbostratus
Combine iRules
When I try and combine these 2 rules into one, the second half of the rule (elseif) doesn't seem to work properly. I have the rules listed seperately on the VIP, but I have 40 rules and would like to...
hooleylist
Dec 05, 2007Cirrostratus
Hi Jeff,
A switch statement (Click here) would help you organize the two rules into one:
when HTTP_REQUEST {
log local0. "Client [IP::client_addr] requested [HTTP::host][HTTP::uri]"
switch -glob [HTTP::uri] {
*/ABC* -
*/DEF* {
log local0. "Client [IP::client_addr] matched first case, sending to pool WLS-V10."
pool WLS-V10
}
*/XX3333* {
log local0. "Client [IP::client_addr] matched second case, rewriting URI to /ABC/, sending to pool WLS-V10."
HTTP::uri [string map {/XX3333/ /ABC/} [HTTP::uri]]
pool WLC-V10
}
*/XX4279* {
log local0. "Client [IP::client_addr] matched third case, rewriting URI to /ABC/, sending to pool WLS-V10."
HTTP::uri [string map {/XX4279/ /ABC/} [HTTP::uri]]
pool WLC-V10
}
default {
log local0. "Client [IP::client_addr] didn't match any case."
}
}
}
This should exactly replicate your two rules. Note that the -glob flag on switch enables wildcard matching. So the *'s will match any number of any characters. If you only want to match requests with URIs starting with /ABC or /DEF, use /ABC* and /DEF*.
If you're not sure that the rule is working correctly, uncomment the log statements and check the /var/log/ltm log file (tail -f /var/log/ltm).
Aaron
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