Forum Discussion
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
Redirect to:
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
- What_Lies_Bene1
Cirrostratus
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
Cirrocumulus
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
- nathe
Cirrocumulus
Oops, missed the final " after $query.
- Pirlo
Nimbostratus
Will try against actual backend servers shortly.
But using fiddler it appears I am getting the correct response
Will post later
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
