Here is the solution that works:
when HTTP_REQUEST {
if {[HTTP::uri] contains "/study1"} {
HTTP::header remove "Accept-Encoding"
HTTP::header replace Location [string map -nocase {"study1" "ServicesStudyDB"} [HTTP::header Location]]
HTTP::uri "/ServicesStudyDB"
HTTP::uri [string map -nocase {"study1" "ServicesStudyDB"} [HTTP::uri]]
STREAM::disable
}
}
when HTTP_RESPONSE {
if {[HTTP::header Content-Type] contains "text"}{
set study1_uri [string map -nocase {"/ServicesStudyDB" "/study1"} [HTTP::header "Location"]]
HTTP::header replace Location $study1_uri
HTTP::header replace Location [string map -nocase {"ServicesStudyDB" "study1"} [HTTP::header Location]]
Replace 'old_text' with 'new_text'
STREAM::expression {@ServicesStudyDB@study1@}
Enable the stream filter for this response only
STREAM::enable
}
}