Forum Discussion

Nolan_Jensen's avatar
Nolan_Jensen
Icon for Cirrostratus rankCirrostratus
Nov 18, 2020

Redirect to portion of a query string?

Hello All,

 

I am trying to figure out correct code for an iRule to redirect to a different host and append just a portion of the query string to the end of that redirect.

 

Example:

If customer goes to https://domain1.com/test.aspx?account=12345678 redirect them to https://domain2.com/12345678

 

I am able to use code below to add ?account=12345678 to the redirect but need it to just be the account number not the ?account= part of the query string.

my code results in this: https://domain2.com/?account=12345678

 

So ideally need to parse that query statement and pull just the account number to add to end of redirect.

 

Any help would be greatly appreciated. Thank you!

 

Here is the code I have that gets me close.

 

when HTTP_REQUEST {
  if { [string tolower [HTTP::uri]] contains "test.aspx" } {
        HTTP::redirect " https://domain2.com/[HTTP::query]"
    }
}