Emulate IE7 header insertion in response for IE8
Problem this snippet solves:
Insert an HTTP header in responses to Internet Explorer 8 clients which tells the client to emulate Internet Explorer 7 when rendering the web application content.
earton wrote in this post:
http://devcentral.f5.com/Default.aspx?tabid=53&forumid=5&postid=56407&view=topic
With the release of IE8 yesterday, I need to be able to automatically make users who have IE8 installed to be forced into an IE7 compatible mode. I have read some articles on Microsoft that details doing this by the use of the following commands
< ?xml version="1.0" encoding="utf-8"?> < configuration> < system.webServer> < httpProtocol> < customHeaders> < clear /> < add name="X-UA-Compatible" value="IE=EmulateIE7" /> < /customHeaders> < /system.webServer> < /configuration>
Is it possible to do the same thing in an iRule when a client connects to a virtual server which hosts IIS servers.
Joe provided the suggestion of using an iRule to insert the corresponding HTTP header in the response. Here is an example which implements this functionality.
Code :
when HTTP_REQUEST { # Check if User-Agent header is IE 8 if { [HTTP::header User-Agent] contains "MSIE 8" } { set IE8Resp 1 } else { set IE8Resp 0 } } when HTTP_RESPONSE { if { $IE8Resp } { log local0. "[IP::client_addr]:[TCP::client_port] Inserting X-UA-Compatible: IE=EmulateIE7 header" HTTP::header insert "X-UA-Compatible" "IE=EmulateIE7" } }