Rewrite (Search-Replace) HTML on the fly

From Tech-Wiki
Revision as of 18:53, 20 May 2019 by Fabricio.Lima (Talk | contribs) (Created page with "Category:F5 Networks '''Back to iRules''' This can also be done via LTM Rewrite profile when HTTP_REQUEST { set replace_content 0...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Back to iRules

This can also be done via LTM Rewrite profile

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  
        }  
    }  
  }