OK, could be a few things but lets start with checking both the if and the expression using some logging - add this here;
Set a variable so we know to do custom stream rewrite
set strReplace 1
log local "Request matches, setting replace variable"
This here;
when HTTP_RESPONSE {
if { [info exists strReplace] && $strReplace && [HTTP::header "Content-Type"] contains "html" } {
log local "Variable exists, variable is set to 1 and content type contains html"
If we hit your "Match1" log statement after the first two we know its the stream expression. I must say it looks rather complex.