Forum Discussion
lunitic_56137
Aug 15, 2012Nimbostratus
Switch statement not working
I have an 11.2 deployment that is using this iRule. The issue is that the Switch statement will not work.
"when HTTP_REQUEST {
switch -glob [HTTP::uri] {
"/uri1" -
"/uri2" {
HTTP::redirect "https://newvirtual.server.com"
}
"/uri3" -
"/uri4" {
node 1.1.1.1 80
}
}
if { [matchclass [HTTP::uri] contains uri_address_external_file ] } {
log local0. "Match found Sending to J2EE_Pool"
pool J2EE_Pool
}
else {
log local0. "No match in the list. Forwarding to Offsite destination"
HTTP::redirect "http://other.site.com"
}
}"
Originally I had it between the IF and the ELSE and it worked. Moving it up to the top makes it not work at all. Ideas?
- Can you provide any more details? It's hard to figure out from here without knowing the test cases you are passing in and what results you are seeing (or not).
switch -glob [HTTP::uri] { "/uri1" - "/uri2" { HTTP::redirect ... } "/uri3" - "/uri4" { node 1.1.1.1 80 } default { if { [matchclass ... } { pool J2EE_pool } else { HTTP::redirect http://other.site.com } } }
- lunitic_56137Nimbostratusok, more details then.
- lunitic_56137NimbostratusI changed the rule and I still cannot get it to match on uri1-4. The other statements work fine.
- hooleylistCirrostratusCan you log the value of the URI and verify it's what you're expecting fo rthe URI1-4 cases? If you want to compare paths and not the full URI (path + query string = URI), you can use [HTTP::path] instead of [HTTP::uri].
- lunitic_56137NimbostratusYes the logs show the correct URI's. I will try the path statement instead of uri.
- Just trying to clarify things. Are you saying that with a URI of "/uri3" the switch is not matching and falling through and executing the "node 1.1.1.1 80" command, or are you saying that it is calling the command but the command has no effect?
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