Forum Discussion

dhlee659_281925's avatar
dhlee659_281925
Icon for Nimbostratus rankNimbostratus
Aug 17, 2016

html tag remove

Hi,

 

I'd like to modify HTML content of a web page with an iRule.

 

In this case, I have a tag : ..... that I'd like to remove with ..... or .....

 

Can you help me?

 

Thanks a lot.

 

  • Hi dhlee659,

    you have to attach a STREAM profile to your Virtual Server and then use the iRule below as a starting point...

     

     

    when HTTP_REQUEST {
         Remove "Accept-Encoding" header to force the server to send clear text responses. 
        HTTP::header remove "Accept-Encoding"
        Disable STREAM profile for HTTP_REQUEST bodys
        STREAM::disable
    }
    when HTTP_RESPONSE {    
        if { [HTTP::header value Content-Type] eq "text/html" } then {
             Look for "" and replace with ""
            STREAM::expression {@@@}
             Enable STREAM profile for the received HTTP_RESPONSE content
            STREAM::enable
        }
    }
    

     

     

    Note: You may also add a [if] conditions in the HTTP_REQUEST event to apply the content replacement just for certain [HTTP::uri]'s.

    Note: If you need to replace the entire ..... including the "....." portion, then please post the HTML code of the entirely. Depending on the existence of dynamic content, it could be required to use a [STREAM::match] syntax to peform more complex content replacements.

    Note: Instead of removing the Accept-Encoding header during HTTP_REQUEST, you could also use a compression profile on your virtual server and make sure the "Keep Accept Encoding" option is disabled. This would allow you to still compress the content before sending it to the client.

    Cheers, Kai