Forum Discussion
DB
Nimbostratus
May 11, 2007Can iRule be used to modify HTML code itself being passed?
Can iRules be used to modify the contents of an HTML page being returned to a client HTTP request? For example, if HTML page includes any link that begins with "http://images.dot.com/*" change it to "...
May 11, 2007
Of course you can modify the content in the response. You can use the HTTP::payload command to return the current payload into a variable, modify the content in that variable, and then issue the HTTP::payload command again passing in the new payload. To perform substitutions, you can use the TCL regsub or "string map" commands.
But, if you are doing a simple conversion from one string to another, the easiest approach is with the stream profile associated with your virtual server. This thread
http://devcentral.f5.com/Default.aspx?tabid=53&view=topic&forumid=5&postid=13504
Click here
goes over many options for replacing content in the response. The main thing to remember is that you need to have "Response Chunking" set to "Rechunk" in your HTTP profile if you are going to modify the length of the response payload.
-Joe
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects