Forum Discussion
Brent_Sachnoff_
Nimbostratus
Oct 23, 2007Using switch with uri
I'm having some issues using the switch command and uri's. I believe the switch command is only for EQUALS to something for it to work properly which means this wouldn't work at all. Here is a sample...
hoolio
Cirrostratus
Oct 24, 2007You can use the -glob flag on switch to enable wildcards. By default, switch uses -exact to require exact matches. Here is an example:
when HTTP_REQUEST {
switch -glob [HTTP::uri] {
"/search/*" { pool search }
"*/int_search/" { pool search }
"/pictures/" { node 10.4.43.1 80 }
"/" { HTTP::redirect "https://[HTTP::host]/IMT/LoginAction.go" }
default {
pool www
}
}
}/search/* would match anything starting with /search/. */int_search/ would match anything ending with /int_search/. /pictures/ would match only requests to exactly that URI.
For details on switch options, check the TCL page (Click here). Note that the -nocase flag described in the TCL page is not enabled for iRules. If you want to perform a case insensitive comparison, set the URI to lower case using 'switch -glob [string tolower [HTTP::uri]]'.
Aaron
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