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]]
if { $uri contains "blog" } {
pool MIS-WEB21-CS
}
else {
pool MIS-WEB20-4
}
}
I would like to add uri contains "msgs" and "theme" to this rule. So, if the uri contains blog or msgs or theme, it will redirect to pool MIS-WEB21-CS if not then go to pool MIS-WEB20-4. I have tried it a few different ways with no luck.
- Colin_Walker_12Historic F5 AccountWhile 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.
class myURIs { "blog" "msgs" "theme" }
when HTTP_REQUEST { if { [matchclass [string tolower [HTTP::uri] ] contains $::myURIs ] } { pool MIS-WEB21-CS } else { pool MIS-WEB20-4 } }
- Dave_Horsey_225
Nimbostratus
I get the following error when I try to save the rule: - The class is a data group. The "class" string is used sometimes because that is the internal format used in the bigip.conf file. If you go into the iRules section of the GUI, you'll see a tab titled "Data Group List". Create a string data group named "myURIs" with the given items and you should be set.
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