Forum Discussion
Match "=" sign in URI then insert into redirect
How do I grab everything after the equal sign then insert it into my redirect?
I have no idea how to put the framework for this rule together and have no code at this point. Everything I have tried fails. When I try to google or search devcentral I am finding info on the equal or ne function.
Original Request that I need to grab everything after the equal sign https://domain.com/dir/ectory/cancelOrderForm?refundInfo=VALUETHATISNEEDED
Redirect and insert
https://domain.com/dir/ectory/cancelOrderVerify.action?token=VALUETHATISNEEDED
I am assuming I need to set it then insert it something like the below
HTTP::redirect https://domain.com/dir/ectory/cancelOrderVerify.action?token=$EVERYTHINGAFTEREQUALSIGN
3 Replies
- nitass
Employee
e.g.
config [root@ve11a:Active:In Sync] config tmsh list ltm rule qux ltm rule qux { when HTTP_REQUEST { set qvalue [URI::query [HTTP::uri] refundInfo] if { [HTTP::path] eq "/dir/ectory/cancelOrderForm" and $qvalue ne "" } { HTTP::redirect "https://[HTTP::host]/dir/ectory/cancelOrderForm.action?token=$qvalue" } } } test [root@ve11a:Active:In Sync] config curl -I http://172.28.24.10/dir/ectory/cancelOrderForm?refundInfo=VALUETHATISNEEDED -H "Host: domain.com" HTTP/1.0 302 Found Location: https://domain.com/dir/ectory/cancelOrderForm.action?token=VALUETHATISNEEDED Server: BigIP Connection: Keep-Alive Content-Length: 0 - What_Lies_Bene1
Cirrostratus
OK, so to extract that value;
set EVERYTHINGAFTEREQUALSIGN [findstr [HTTP::uri] "=" "1"] If this causes the first character to be removed, remove the "1"And for the redirect;
HTTP::redirect https://domain.com/dir/ectory/cancelOrderVerify.action?token=$EVERYTHINGAFTEREQUALSIGNIf may be more efficient to actually use findstr with [HTTP::query] and replace domain.com with [HTTP::host] but I'm sure the difference is negligible.
- Pirlo
Nimbostratus
Thanks - Works great
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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