Hi,
I think this should be equivalent to the Apache rewrite rule:
when HTTP_REQUEST {
Check if the host is test.domain.com and the path does not already start with /web/foo
if {[string tolower [HTTP::host]] eq "test.domain.com"}{
if { not ([HTTP::path] starts_with "/web/foo")}{
Prepend /web/foo to the path
HTTP::path "/web/foo[HTTP::path]"
}
}
}
And here's a version which works with a stream profile to rewrite the response content and redirect Location header from /web/foo to nothing:
when HTTP_REQUEST {
Disable the stream filter by default
STREAM::disable
Check if the host is test.domain.com and the path does not already start with /web/foo
if {[string tolower [HTTP::host]] eq "test.domain.com"}{
if { not ([HTTP::path] starts_with "/web/foo")}{
Prepend /web/foo to the path
HTTP::path "/web/foo[HTTP::path]"
}
}
}
when HTTP_RESPONSE {
Rewrite redirects
if {[HTTP::is_redirect] && [URI::path [HTTP::header Location]] starts_with "/web/foo"}{
HTTP::header replace Location [string map {/web/foo ""} [HTTP::header Location]]
}
Set the stream expression for text responses
if {[HTTP::header Content-Length] contains "text"}{
STREAM::expression {@/web/foo@@}
STREAM::enable
}
}
Aaron