Forum Discussion
Siddharth_Sezhi
Nimbostratus
Sep 27, 2006need to make url redirects to be case in-sensitive
We wanted to redirect to a particular site when the url has /abc i implemented irule like the one below. It seems to work but the problem is its case sensitive. when client /ABC or /Abc except for the...
Sep 27, 2006
surrounding the HTTP::uri with a "string tolower" command should do the trick. But, you'll probably want to do it for each conditional statement. An alternative, and more optimal, approach would be to use a switch statement like this:
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] {
"*cgi" {
pool cgi_pool
}
"/abc*" {
pool abc_servers
}
}
}The -glob option uses wildcards and is not as expensive as a regular expression check. Your alternative would have been something like this:
when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] ends_with "cgi" } {
pool cgi_pool
} elseif { [string tolower [HTTP::uri]] starts_with "/abc" } {
pool abc_servers
}
}But, this does two string conversions to lower case. You could also store the lowercase uri in a variable
when HTTP_REQUEST {
set uri [string tolower [HTTP::uri]]
if { $uri ends_with "cgi" } {
pool cgi_pool
} elseif { $uri starts_with "/abc" } {
pool abc_servers
}
}Lots of options...
-Joe
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
