Problem this snippet solves: iRule to replace the functionality of Apache Webserver ProxyPass and ProxyPassReverse functions. Allows you to do hostname and path name modifications as HTTP traffic pa...
@Ross, your remark (4) is right, the iRule seems to rewrite only URLs in responses if the same URL appeared in the request. This means the purpose of the iRule is to provide rewriting for independent virtual hosts/paths which are not referrring each other, if they do they would need to use external URLs not internal references.
I would suggest using APM portal access mode instead of trying to extend this irule code. Portal access also provides additional features for URLs in CSS and JS code.