Forum Discussion
Former Member
Jun 27, 2017Conditionally inject text into HTML responses
Hello,
An LTM needs to inspect a server's response pages and rewrite the HTML so that, for every URL written without a specific URI path, the URI path is inserted.
Example:
Server sends back calls to URL
http://server.example
/path/image.jpeg
-- Ok, no action
Server sends back calls to URL
http://server.example/image.jpeg
-- Need to inject /path
I haven't been able to get a working syntax, any help will be immensely appreciated.
- cjuniorNacreous
Hi Rodolfo, I had no lucky with regex exclude "(?!path)", so I would to try this way:
when HTTP_REQUEST { STREAM::disable HTTP::header remove "Accept-Encoding" } when HTTP_RESPONSE { if { [HTTP::header value Content-Type] contains "text" } { \w{0,4} = 'path' lenght STREAM::expression {@server\.example/\w{0,4}@@} STREAM::enable } } when STREAM_MATCHED { if { ! ([STREAM::match] ends_with "path") } { STREAM::replace [string map {/ /path/} [STREAM::match]] } }
Regards.
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