Forum Discussion
VernonWells
Employee
when HTTP_REQUEST {
if { [HTTP::path] equals "/test" } {
HTTP::path "/"
pool test
}
}
This will match exactly (and only) /test and nothing else.
Josh_Jacobson_4
Oct 04, 2016Altostratus
You can use [HTTP::uri] to preserve any GET vars (if you don't care about GET vars [HTTP::path] is fine too of course). Here's one way to strip the first segment of the path and send the rest on. I broke it out into two statements in case that's easier to read, and there's a one-liner version of it at the end too.
when HTTP_REQUEST {
if { [HTTP::uri] starts_with "/test/" } {
This will find the position of the second slash (starts searching at position 1; first slash is position 0)
set slashpos [string first / [HTTP::uri] 1]
Substring from the position of the second slash through the end of the URI
set newuri [substr [HTTP::uri] $slashpos]
Here's the one-liner to accomplish the same thing (it was just easier to comment as two statements):
set newuri [substr [HTTP::uri] [string first / [HTTP::uri] 1]]
log local0. "New URI: $newuri"
HTTP::uri $newuri
pool test
}
}