18-Nov-2020
10:03
- last edited on
22-Nov-2022
15:12
by
JimmyPackets
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]"
}
}
Solved! Go to Solution.
18-Nov-2020
10:42
- last edited on
04-Jun-2023
21:11
by
JimmyPackets
Hi Nolan Jensen,
when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] contains "test.aspx" } {
HTTP::redirect "https://domain2.com/[URI::query [HTTP::uri] account]"
}
}
18-Nov-2020
10:42
- last edited on
04-Jun-2023
21:11
by
JimmyPackets
Hi Nolan Jensen,
when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] contains "test.aspx" } {
HTTP::redirect "https://domain2.com/[URI::query [HTTP::uri] account]"
}
}
18-Nov-2020 13:23
thank you for the response. I will let you know if it works once I have a chance to test it.
19-Nov-2020 13:04
Sorry for slow response. That did work. thank you very much!