Forum Discussion
Nicolas_MENOUX_
Nimbostratus
Apr 29, 2009STREAM_MATCHED for regexp replace ?
Hi,
I'm using an IRule to replace Http content coming from our web servers in order to change image relative path to absolute path as described below :
when HTTP_REQUEST ...
hoolio
Cirrostratus
May 01, 2009Here the basic idea in one shot:
when HTTP_REQUEST {
Check if the client used a host header
if {[string length [HTTP::host]]}{
set host [HTTP::host]
} else {
Use the VIP address instead
set host [IP::local_addr]
}
}
when HTTP_RESPONSE {
Check if the response was a 200 and text
if {[HTTP::status] == 200 and [HTTP::header "Content-Type"] contains "text"} {
STREAM::expression "@'/images/@'http://media\.$host\.com/images/@"
STREAM::enable
}
STREAM::disable
}
}
Note that the double quotes allow variable expansion to take place and work around a bug in the LTM code with unquoted //'s.
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
