Jump to content
Toggle menu
  • 51 articles
  • 24 files
  • 4 users
  • 750 edits
Tech-Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Rewrite (Search-Replace) HTML on the fly

From Tech-Wiki


Technical reference for Rewrite (Search-Replace) HTML on the fly.

Reference

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

See also