Forum Discussion
Pete_Paiva_7147
Nimbostratus
Mar 26, 2007Modify iRule to ignore case sensitivity in URI
Here's my current iRule:
when HTTP_REQUEST {
set uri [HTTP::uri]
if { $uri contains "/crn" } {
pool pdam.com-HTTP
} elseif { $uri contains "/dmz04319...
Mar 26, 2007
The builtin TCL "string tolower" command should do what you want.
when HTTP_REQUEST {
set uri [string tolower [HTTP::uri]]
if { $uri contains "/crn" } {
pool pdam.com-HTTP
} elseif { $uri contains "/dmz0431993" } {
pool www.domain.com-8683
} elseif { $uri contains "/dmz0431994" } {
pool www.domain.com-8683_appserv2
}
}A couple of comments on your iRule.
If you are using the contains operator, then any string match within the URI will get picked up regarless of if it's the first on (ie. /crn, /foo/crn). From your example, it's implied, that you are comparing the first part of the URI. If so, you might want to use the "starts_with" operator in place of "contains".
Also, here's an alternate approach to your iRule using a switch statement (switch statements are a touch faster than if/elseifs.
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] {
"/crn*" {
pool pdam.com-HTTP
}
"/dmz0431993*" {
pool www.domain.com-8683
}
"/dmz0431994*" {
pool www.domain.com-8683_appserv2
}
}This is analogous to your previous iRule with the "starts_with" operator. If you want to make it like a "contains" comparison, just prepend each string match with another "*".
Probably more info than you wanted, but oh well, it's Monday...
-Joe
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