Forum Discussion
Brian_Deitch_11
Apr 23, 2009Historic F5 Account
Replace HTML code with multiple links
So here is my dilemma. I need to create an iRule that will:
1. Match a link
2. Replace each link with one from a list.
So, on the response request, the F5 WA will match d...
Brian_Deitch_11
Apr 29, 2009Historic F5 Account
Well it took an act of God and some great help from Greg with F5 support but we accomplished the task at hand!
when RULE_INIT {
set this to 0 for production
set debug 1
}
when HTTP_RESPONSE {
Counter goes from 1 to 10
set data_counter 1
Disable the stream filter by default
STREAM::disable
Check if response type is html or javascript
if { ( [HTTP::header value Content-Type] contains "text/html" ) or ( [HTTP::header value Content-Type] contains "javascript" )}{
Match any http://data. and don't automatically replace it with anything
STREAM::expression "@http://data\.mydomain\.com@DUMMY@"
Enable the stream filter for this response only
STREAM::enable
}
}
when STREAM_MATCHED {
if { $::debug >= 1 } { log local0. "[IP::client_addr]:[TCP::local_port]: matched: [STREAM::match], replaced with: [string map [list "data" [format "data%u" $data_counter] ] [STREAM::match] ]" }
STREAM::replace [string map [list "data" [format "data%u" $data_counter] ] [STREAM::match] ]
Iterate the data_counter
set data_counter [ expr { $data_counter % 10 + 1 } ]
}
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