Forum Discussion
Nick_Matthews
Cirrus
Aug 21, 2008Search and Replace with iRule
Hi,
I am hoping someone can help.
What I want to do is search in the header for a specific user agent and then find and replace a specific word in the html. Can some one give me some pointers on how I might do this.
This is what I have so far:
when HTTP_REQUEST {
if { [HTTP::header "User-Agent"] contains "xxx"}
{
How do I now search for the text and replace it?
Any help would be appreciated.
5 Replies
- OK,
- Nicolas_Menant
Employee
Hi,when HTTP_REQUEST { if {[HTTP::uri] contains "/admin/"} { HTTP::uri [string map {"/admin/" "/secret/"} [HTTP::uri]] } }
- Hi,
- Nicolas_Menant
Employee
Sorry i missed this part then you can try something like this:when HTTP_REQUEST { set replace_content 0 if {[HTTP::uri] contains "/atoz/"} { set replace_content 1 } } when HTTP_RESPONSE { if {$replace_content equals "1"} { Disable the stream filter by default STREAM::disable Check if response type is text if {[HTTP::header value Content-Type] contains "text" and [HTTP::header "User-Agent"] contains "***"}{ Replace STREAM::expression "@123@xyz@ @456@xyz@" Enable the stream filter for this response only STREAM::enable } } }
- Thanks very much, thats exactly what I wanted :-)
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