Forum Discussion

Pirlo's avatar
Pirlo
Icon for Nimbostratus rankNimbostratus
Jun 05, 2014

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

  • 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
    
    
  • 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=$EVERYTHINGAFTEREQUALSIGN
    

    If 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.