Forum Discussion

Village_Idiot's avatar
Village_Idiot
Icon for Nimbostratus rankNimbostratus
Nov 16, 2022

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 Examp...
  • CA_Valli's avatar
    Nov 17, 2022

    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 value

    when 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