need 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 exact /abc it doesnt seem to work. we wanted to make it case in-sensitive. Kindly help me in this regard.

when HTTP_REQUEST {

if { [HTTP::uri] ends_with “cgi” } {

pool cgi_pool

} elseif { [HTTP::uri] starts_with “/abc” } {

pool abc_servers

}

}

Regards

Siddharth S

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

Hi Joe,

Thanks for ur help. I used string tolower and its working successfully the way we wanted.

Thank u once again.

Regards

Siddharth S