Forum Discussion
when HTTP_REQUEST {
if { [HTTP::path] equals "/test" } {
HTTP::path "/"
pool test
}
}
This will match exactly (and only) /test and nothing else.
- JWhitesPro_1928Oct 04, 2016Cirrostratus
I will test this but will it effectively just remove the /test so that if a user goes to:
myserver.com/test/documents/clinton.pdf that it would rewrite it to just /documents/clinton.pdf because that is what the backend pool server would be expecting (it wouldn't have a path for /test)
- Josh_Jacobson_4Oct 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 } }
- Josh_Jacobson_4Oct 04, 2016Altostratus
oops, looking at Vernon's answer below I should have put in a test for no second slash - sorry if my answer does more harm than good!
-Josh