Do you want to redirect the client with the updated path-only location or do you want to rewrite it before the request is sent to the pool? Do you want to do this with all requests that contain a query string?
With a redirect, the browser’s address bar will show the update. With a rewrite it will not be modified. Here are two examples:
Rewrite:
when HTTP_REQUEST {
Check if there is a query string in the URI
if {[string length [HTTP::query]]}{
Rewrite the URI to remove the query string
HTTP::uri [HTTP::path]
}
}
Redirect:
when HTTP_REQUEST {
Check if there is a query string in the URI
if {[string length [HTTP::query]]}{
Redirect the client to the same host and the path (URI without the query string)
HTTP::redirect http://[HTTP::host][HTTP::path]
}
}
For more info on the commands, you can check the iRules wiki pages:
If you do want to send back a response with the requested path in the payload, the rule you posted originally should work. Was there something not working with that?