Technical Forum
Ask questions. Discover Answers.
cancel
Showing results for 
Search instead for 
Did you mean: 

iRule path redirect doesn't work with question mark

m00t
Altostratus
Altostratus

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: www.mysite.com/?cont=813 it goes to the Pro pool instead of the Web pool. Any ideas are very much appreciated!

2 REPLIES 2

SanjayP
MVP
MVP

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 } } }

 

wlopez
Cirrocumulus
Cirrocumulus

"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.