Forum Discussion
alteration to an existing irule
Hi,
This is definitely a newbie question, so apologies in advance!
I have a context switch within an irule like so:
"/stuff/place*" {
pool my_pool
return
}
I would now like to point /stuff* to the same pool, but in the following manner:
"/stuff*" {
if { some conditions } {
HTTP::redirect "http://www.site.com/overhere/"
} else {
pool my_pool
}
My question is, can the two context switches co-exist within the same irule or will the switch for /stuff* overrule the entry for /stuff/place* ?
- Brian_69413NimbostratusTCL evaluates switch statements in order, so you should put the more specific towards the top and the less specific at the bottom...
- OttimoMassimo_1NimbostratusThanks for the reply Brian. I'll test that and let you know how it goes.
- nitassEmployee
[root@orchid:Active] config b rule myrule1 list rule myrule1 { when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/stuff/place*" { log local0. "URI is [HTTP::uri], /stuff/place* is triggered." } "/stuff*" { log local0. "URI is [HTTP::uri], /stuff* is triggered." } default { log local0. "URI is [HTTP::uri], default is triggered." } } } } Sep 16 01:21:03 tmm tmm[7053]: Rule myrule1 : URI is /, default is triggered. Sep 16 01:21:07 tmm tmm[7053]: Rule myrule1 : URI is /stuff, /stuff* is triggered. Sep 16 01:21:14 tmm tmm[7053]: Rule myrule1 : URI is /stuff123, /stuff* is triggered. Sep 16 01:21:19 tmm tmm[7053]: Rule myrule1 : URI is /stuff/place, /stuff/place* is triggered. Sep 16 01:21:21 tmm tmm[7053]: Rule myrule1 : URI is /stuff/place123, /stuff/place* is triggered.
- Colin_Walker_12Historic F5 AccountYour syntax actually looks just fine, you just need to combine the two with, as the above poster said, the more specific criteria first. Make sure you're closing the switch cases, and you're good to go.
- OttimoMassimo_1NimbostratusHi,
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