Forum Discussion
Dave_Horsey_225
Nimbostratus
Apr 12, 2006multiple "uri contains" matches
I am trying to write a rule that will catch many different uri matches. The orginal rule that I am working off is as follows:
when HTTP_REQUEST {
set uri [string tolower [HTTP::uri]]...
Colin_Walker_12
Apr 12, 2006Historic F5 Account
While you could just put multiple "if" statements in your rule, the most efficient way to do this, especially if you start talking about many different matches, rather than just 3, is to use a class, and the matchclass function.
First, you'd set up a data group, either via the gui, as type "String" or via the cli.
It would look something like this:
class myURIs {
"blog"
"msgs"
"theme"
}Then, you'd update your rule to perform a search of the class, and act accordingly, like so:
when HTTP_REQUEST {
if { [matchclass [string tolower [HTTP::uri] ] contains $::myURIs ] } {
pool MIS-WEB21-CS
} else {
pool MIS-WEB20-4
}
}This way, if the URI matches anything in the myURIs class, the matchclass will return true, and traffic will go to the MIS-WEB21-CS pool.
This also makes it easy to manage which URIs this is true for. Simply add or remove them from the class as needed, and you won't have to update the rule at all.
HTH,
Colin
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