Forum Discussion

Pirlo's avatar
Pirlo
Icon for Nimbostratus rankNimbostratus
Sep 11, 2013

URI Redirect only using a portion of the original URI

I usually dont like to ask for help since DevCentral usually has posts that I can manipulate or dissect and get what I need with a little bit of tuning.

Essentially I need to only grab a portion of URI and insert it into the redirect.

So here is the basics of what I am trying to do.

When request comes in matching the below

https://test.this.com/MyTest/ResetPassword.action?verifyPasswordToken=&token=8AD4316AB786615C9F54D25A5572EE8C77B87BDB

Redirect to:

https://www.testthis.com/en-us/home.html?verifyPasswordToken=&token=8AD4316AB786615C9F54D25A5572EE8C77B87BDB

But the only portion of the URI I now need is

?verifyPasswordToken=&token=8AD4316AB786615C9F54D25A5572EE8C77B87BDB

instead of the full URI

MyTest/ResetPassword.action?verifyPasswordToken=&token=8AD4316AB786615C9F54D25A5572EE8C77B87BDB

So from ?verifyPasswordToken(always stays the same) to the end of the URI(which will change) I now need to append that into the redirect

This is the rule I had in place before realizing I was grabbing the whole URI

when HTTP_REQUEST {

 if {[HTTP::host] equals "test.this.com" } {

     if { [HTTP::uri] contains "ResetPassword.action?verifyPasswordToken=&token=" } { 

         log "matched reset password" 

         HTTP::redirect "https://www.testthis.com/en-us/home.html[HTTP::uri]" 

 } elseif {[HTTP::host] equals "test.this.com" } { 

     if { [HTTP::uri] equals "/MyTest" } { 

         log "matched root URL" 

         HTTP::redirect "https://www.testthis.com/en-us/home.html" 

     }

} } }

Any pointers would help.

4 Replies

  • You just need to redirect using the HTTP::query, plus the ? which isn't included. So, something like this:

    HTTP::redirect "https://www.testthis.com/?[HTTP::query]]"

  • nathe's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus

    Blue, couple of ways to do this I think. Looks liked you're after the http query part of the uri. So after you've logged a match to reset password you could also "set query [string tolower [HTTP::query]" and then the redirect could be HTTP::redirect "https://www.test.this.com/en-us/home.html?$query

     

    See if that works. Can't test myself at the mo but I'm sure I'll be corrected if wrong. Rgds, N

     

  • Pirlo's avatar
    Pirlo
    Icon for Nimbostratus rankNimbostratus

    Will try against actual backend servers shortly.

     

    But using fiddler it appears I am getting the correct response

     

    Will post later