Village_Idiot
Nov 16, 2022Nimbostratus
Capture part of URL to redirect to another
I have a request to redirect from one URL to another based on the word "LOAN" in the query part of the URL. They only want to keep a random length string from the old URL to the redirected one
Example
From
To
https://website2.domain.com/path/app.aspx?acctNum=38932940&acctType=LOAN&type=Documents
In the examples, the only part needed to capture is "38932940" and use it as a variable in the redirected URL. The problem is this is random in length. Any ideas on how to achieve this?
Hello there,
if the requested information is always stored in variable KT1112_0_0_0= at request time, this script will capture exact variable value (not bound to length) and insert it in redirect url as acctNum valuewhen HTTP_REQUEST { if { [HTTP::uri] contains "LOAN" }{ set acctNum [findstr [HTTP::query] "KT1112_0_0_0=" 13 &] HTTP::redirect "https://website2.domain.com/path/app.aspx?acctNum=$acctNum&acctType=LOAN&type=Documents" } }
It's working in my lab