Forum Discussion
How to do a NOT URI with switch -glob
There is a VIP with an irule on it using the switch -glob format. Something like
switch [HTTP::uri] {
"/foo/* -
"/bar/* { pool blah
} default { pool default
}
}
Now the application team that own the VIP would like to change that to something like
switch [HTTP::uri] {
**NOT** "/foo/* -
"/bar/* { pool blah
} default { pool default
}
}
So that if the conditions do not match either /foo/ or /bar/, than redirect to pool blah. Not sure what the right syntax for that would be.
1 Reply
- VernonWells
Employee
Without resorting to regular expression matching (which should be avoided), I believe there is no way to do the kind of negation that you are describing with a
. This leaves you with two options:switchswitch [HTTP::uri] { "/bar/*" { pool blah } default { if { !([HTTP::uri] starts_with "/foo/") } { pool blah } else { pool default } } }or
if { [HTTP::uri] starts_with "/bar/" || !([HTTP::uri] starts_with "/foo/") } { pool blah }then just set the VS default pool to "default". Unhappily, in this, you can't avoid the double-evaluation in the worst case.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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