Forum Discussion
Brian_Kenworthy
Nimbostratus
Oct 03, 2006Inspect URI without Case Senstivity?
Hello all,
I have created the following rule to redirect traffic based on the URI to another pool, however, I want the rule to ignore case sensitvity within the URI string. Here is my rule:
when HTTP_REQUEST {
set uri [HTTP::uri]
if { $uri matches_regex "/_xml/ORS/status.asp*" }{
pool mypool_B2B_SSL
} else {
pool mypool.com_SSL
}
}
If I browse using the exact snytax, everything works fine, but it I use a lower case "ors", it fails i.e. https://mydomain/_xml/ors/status.asp I want the rule to fire on any case change that a user puts into the string.
Thanks in advance for the help.
Brian
- matches_regex is way overkill for a simple string comparison. Regular expressions are very CPU intensive so it's better to not use them if you don't have to.
when HTTP_REQUEST { if { [string tolower [HTTP::uri]] starts_with "/_xml/ors/status.asp" }{ pool mypool_B2B_SSL } else { pool mypool.com_SSL } }
- Brian_Kenworthy
Nimbostratus
Thanks Joe, that did the trick!! - I prefer the switch statement myself (or a data group in combination with the matchclass command if you have a lot more strings to match.
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/_xml/ors/status.asp*" - "/_xml/vendor/status.asp*" - "_xml/client/status.asp*" { POOL mypool_B2B_SSL } default { pool mypool.com_SSL } } }
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