You are on the right track with retrieving the value with HTTP::host but you are just updating a local variable, not the actual host header that is sent. This should work for you.
when HTTP_REQUEST {
if { [HTTP::host] eq "abc.com" } {
HTTP::header replace "Host" "def.com"
}
}
That's it. There is nothing needed to be done on the return trip to the browser because the browser still thinks it's accessing
http://abc.com. That, along with the fact that the URI isn't part of the HTTP response so even if you wanted to, you couldn't inform the browser of the backend switch. The only way to make a browsers address bar change to an updated URI (ie, if you wanted it to display
http://def.com) is to issue a HTTP redirect causing the browser to reissue a new request to the updated address.
-Joe