Forum Discussion
URI dissection for URL rewrite
I'm looking to dissect the URI of an incoming request so that I can then use the parameters to rewrite the URL being passed to the server. So if I have the following URL being sent by a user/application:
I need to get the values of the "to" and "text" so that I can rewrite the URL back to the server as:
I have found this sample that dissects the URI for me though I don't know how to use the values to then rewrite the URL:
when HTTP_REQUEST { log local0. "----------------------" log local0. "URI Information" log local0. "----------------------" log local0. "HTTP:" log local0. "----------------------" log local0. "Path Information" log local0. "----------------------" log local0. "HTTP:" set depth [URI::path [HTTP::uri] depth] for {set i 1} {$i <= $depth} {incr i} { set dir [URI::path [HTTP::uri] $i $i] log local0. "dir[$i]: $dir" } log local0. "Basename: [URI::basename [HTTP::uri]]"
log local0. "----------------------" log local0. "Query Information" log local0. "----------------------" log local0. "HTTP:" set namevals [split [HTTP::query] "&"] for {set i 0} {$i < [llength $namevals]} {incr i} { set params [split [lindex $namevals $i] "="] set pnum [expr $i+1] log local0. "Param[$pnum]: [lindex $params 0]" log local0. "Value[$pnum]: [URI::query [HTTP::uri] [lindex $params 0]]" } }
Any help would be appreciated.
1 Reply
- Michael_Jenkins
Cirrostratus
If I understand correctly, you could use the URI::query command to parse the query parameters... Something like this:
when HTTP_REQUEST { set to [URI::query [HTTP::uri] "to"] set text [URI::query [HTTP::uri] "text"] Update the uri (the additional vars (username, password, from) would have to be set as well. HTTP::uri "cgi-bin/sendsms?username=${username}&password=${password}&from=${from}&to=${to}&text=${text}" }
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