There was a typo in my rule and devcentral does not allow me to edit it, so here's the updated rule:
when HTTP_REQUEST {
Get the middle part of the host
set site [lindex [split [HTTP::host] "."] end-1]
Concatenate midhost to the uri
HTTP::uri "/$site/[HTTP::uri]"
Disable the stream filter for requests
STREAM::disable
Remove this header to prevent server from compression response
HTTP::header remove Accept-Encoding
Replace the host header to match www.xyz.com
HTTP::header replace "Host" "www.xyz.com"
}
when HTTP_RESPONSE {
Rewrite the Location header for redirects
if { [HTTP::header exists Location] }{
HTTP::header replace Location [string map {"https://www.xyz.com" "https://www.abc.com"} [HTTP::header Location]]
}
Rewrite the response content using a stream profile if it is text
if { [HTTP::header Content-Type] contains "text" } {
Set the stream expression with the find/replace strings
STREAM::expression "@www.xyz.com@www.abc.com@"
Enable the stream filter
STREAM::enable
}
}
/Patrik