Forum Discussion
Capture part of URL to redirect to another
- 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 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
Hi Village_Idiot ,
> I have written an iRule script for you and tested it in my home Lab environment.
> First take the iRule :
when HTTP_REQUEST {
if { [HTTP::uri] contains "LOAN"} {
HTTP::redirect "https://website2.domain.com/path/app.aspx?acctNum=[URI::query https://website1.domain.com/path/app.aspx?KT1112_0_0_0=38932940&KY108_0_0=LOAN&clienttype=html&cqid=102 KT1112_0_0_0]&acctType=LOAN&type=Documents"
}
}
#URI::query <uri> <parameter> I used it to Get the numeric value from a specific parameter exists in first uri
it should work with you as its as long you do not have any new parameters you want to add , it’s up to you.
> Read about [URI::query] Function which was my clue to get the desired output.
___________________________________________________________________________
Now , I will share a snap shots from my environment :
1- My irule which is adequate with my environment and published application :
2- URL before Redirection and fetching the parameter value , it "q" Parameter in my environment :
3- URL after Redirection and transfer the "q" value to be stored in parameter "acctNum":
as it is shown "acctNum" parameter has taken the "q" parameter value in the first request and Redirected to the second URL with the targgeted value.
hope it helps you.
Please test it and give me your feedback to save it in my notes if it matches your requirements as it is the first time to use [url::query] Function.
Regards
Mohamed Kansoh
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com