Forum Discussion
how can i rewrite meta refresh url on response
i have the following code for a response:
' '
i am trying to rewrite (via irule, stream) the ip address (xxx.xxx.xxx.xxx) to a FQDN host name url.
my normal http_response irule does not pick up these strings when they are in an Head/Meta tag on response.
is there an irule code that picks this up and changes it.
thanks
Hi Jim,
you may take a look to the STREAM code example below...
when HTTP_REQUEST { Disable STREAM for HTTP_REQUESTs STREAM::disable Remove the "Accept-Encoding" header to see cleartext data on the responses. Note: You could also use a HTTP-Compression Profile to remove the Accept-Encoding header on the server side (Profile Option: Keep Accept Encoding = Disabled). By doing this, you can STREAM the content without losing the ability to support a client side compression. HTTP::header remove "Accept-Encoding" } when HTTP_RESPONSE { Rechunk any Chunked Responses to become able to STREAM those content, without braking the Application. if {[HTTP::header exists "Transfer-Encoding"]} { HTTP::payload rechunk } Apply STREAM expression just to Content-Type = text if {[HTTP::header value "Content-Type"] contains "text"}{ Set the STREAM expression STREAM::expression {@https://1.1.1.1/@https://host.domain.tld/@} Enable STREAM of the current response STREAM::enable } }
Note: If this code does not translate the string https://1.1.1.1/ to https://host.domain.tld/, then you may take a look to the response headers and the HTML content and post them here. It could be either that the "Content-Type" value is different or that the tag is somehow URL encoded..
Cheers, Kai
- JimT02Nimbostratus
still cannot get this to rewrite. if the ip address is in the body of page, then it works. it does not work when it is in the part of oage.
my headers in response are: = PLPARrsp Client Response start --------------------------------- 2016-08-29 18:08:58Local7.Debug192.168.xxx.xxxtmm[22492]: Client xxx.xxx.xxx.xxx:65259 -> (response) 2016-08-29 18:08:58Local7.Debug192.168.xxx.xxxtmm[22492]: Server: IBM HTTP Server/V5R3M0 2016-08-29 18:08:58Local7.Debug192.168.xxx.xxxtmm[22492]: Date: Mon, 29 Aug 2016 23:09:08 GMT 2016-08-29 18:08:58Local7.Debug192.168.xxx.xxxtmm[22492]: Connection: Keep-Alive 2016-08-29 18:08:58Local7.Debug192.168.xxx.xxxtmm[22492]: Accept-Ranges: bytes 2016-08-29 18:08:58Local7.Debug192.168.xxx.xxxtmm[22492]: Content-Type: text/html 2016-08-29 18:08:58Local7.Debug192.168.xxx.xxxtmm[22492]: Last-Modified: Fri, 26 Aug 2016 01:22:16 GMT
my page that has the ip address that I want to rewrite is:
- JimT02Nimbostratus
my page that has the ip address that I want to rewrite is:
Hi Jim,
it doesn't matter where the tag is placed, since STREAM doesn't understand HTML at all. It just sees the flying by bits and bytes an then applies a replacements if a given search pattern is found.
Just combinaed my provided iRule logic with your provided HTML using the iRule below...
when HTTP_REQUEST { Disable STREAM for HTTP_REQUESTs STREAM::disable Remove the "Accept-Encoding" header to see cleartext data on the responses. Note: You could also use a HTTP-Compression Profile to remove the Accept-Encoding header on the server side (Profile Option: Keep Accept Encoding = Disabled). By doing this, you can STREAM the content without losing the ability to support a client side compression. HTTP::header remove "Accept-Encoding" if { [HTTP::path] eq "/stream" } then { set content { hi from jim } HTTP::respond 200 content $content "Content-Type" "text/html" } else { HTTP::path "/stream" virtual [virtual] } } when HTTP_RESPONSE { Rechunk any Chunked Responses to become able to STREAM those content, without braking the Application. if {[HTTP::header exists "Transfer-Encoding"]} { HTTP::payload rechunk } Apply STREAM expression just to Content-Type = text if {[HTTP::header value "Content-Type"] contains "text"}{ Set the STREAM expression STREAM::expression {@https://1.1.1.1@https://www.site.de@} Enable STREAM of the current response STREAM::enable } }
Output:
hi from jim
Cheers, Kai
- JimT02Nimbostratus
almost looks like ie browser issue. this works fine in body of html on ie, just not in the head. all works well on firefox, chrome as well.
- yosen6510Nimbostratus
To use a META Tag to redirect your site is quite easy. With this, use the http-equiv attribute to provide an HTTP header for the value of the content attribute. The following is an example of redirecting current page to another page after 2 seconds.
- mirela6828NimbostratusHTML allows for the specification of meta information within meta tags checker. A popular use of this technique involves specifying redirections or page reloads within HTML code, rather than relying on HTTP headers to do so (for example, HTTP status code 302 Document moved for redirections).
- yosen6510Nimbostratus
It's simple to redirect your site using a meta tags. In order to do this, utilise the http-equiv attribute to supply an HTTP header with the content attribute's value. The next example shows how to switch to a different page after two seconds on the webpage meta tags analyzer.
Recent Discussions
Related Content
* 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