iRule path redirect doesn't work with question mark

Hey everyone!

I know this should be simple, but I’m missing something here. We currently use an irule as follows to switch between pools on a single virtual server:

when HTTP_REQUEST {

switch -glob [string tolower [HTTP::path]] {

“/en/*” -

“/r/*” -

“/kn/*” -

“/up/*”

{ aa

pool UP-WEB

}

default {

pool UP-PRO

}

}

}

This works great for sending the above paths to WEB, and everything else to PRO. However, I also need to send paths with: “?cont=*” to UP-WEB as well. So it looks something like this:

when HTTP_REQUEST {

switch -glob [string tolower [HTTP::path]] {

“/en/*” -

“/r/*” -

“/kn/*” -

“?cont=*” -

“/up/*”

{ aa

pool WEB

}

default {

pool PRO

}

}

}

I believe it’s the question mark causing the problem. When I try to go to URL: Website Hosting - Mysite.com it goes to the Pro pool instead of the Web pool. Any ideas are very much appreciated!

since ?cont= is part of HTTP query instead of uri, iRule would need to look for HTTP::query. You can try below or modify if you need to use switch statment for query as well.

when HTTP_REQUEST {
if { [HTTP::query] starts_with "cont=" }{
pool WEB
return
}
switch -glob [string tolower [HTTP::path]] {
"/en/*" -
"/r/*" - 
"/kn/*" - 
"/up/*"
{ 
pool WEB
} default { 
pool PRO
    }
  }
}

“HTTP::path” will not cover the query content of the requests.

Using “HTTP::uri” instead should solve your issue.

Example:

www.abc.com/login/login.asp?cont=813

HTTP::path = /login/login.asp

HTTP::uri = /login/login.asp?cont=813

Hope that helps.