Implementing the META Switch on Apache
Windows Internet Explorer 8 introduces document compatibility modes that allow Web developers to tell the browser to render their pages in the same way as older versions would. The compatibility mode can be specified on a per-page or per-site basis.
This document describes how to implement a very common document compatibility mode, EmulateIE7, supported by Windows Internet Explorer 8, on a per-site basis, using custom headers in Apache.
For more information concerning the different compatibility modes supported by Windows Internet Explorer 8 and how to implement them on a per-page basis, see META Tags and Locking in Future Compatibility.
Specifying Custom HTTP Response Headers
A document mode can be specified for your Web site by defining a custom header for the site using Apache Web server. The following custom HTTP header will force Windows Internet Explorer 8 to render Web pages as in Windows Internet Explorer 7.
X-UA-Compatible: IE=EmulateIE7
Apache 2.2
To specify an HTTP response header for your Web site using Apache 2.2, you can use the Header directive provided by the mod_headers module. The Header directive can occur almost anywhere within the various configuration files, but the main configuration file is httpd.conf. It can be limited in scope by enclosing them in configuration sections such as <Location>, <Directory>, <Files>, and <VirtualHost>.
By placing the directive in httpd.conf, all pages sent by your server within that scope will include the X-UA-Compatible HTTP response header. This will force Windows Internet Explorer 8 to use the EmulateIE7mode when rendering your pages.
First, you need to ensure that the headers_module is loaded during server initialization. In the httpd.conf file, uncomment the line by removing the “#” at the start of the LoadModule line for headers_module. You can use a text editor such as Notepad to do this. When complete, it should read as below.
LoadModule headers_module modules/mod_headers.so
To add the header to all pages on the server, add the following line to the httpd.conf file after the LoadModule lines.
Header set X-UA-Compatible “IE=EmulateIE7”
It may not be desirable to apply the header to every page on the server. The <Location> directive can be used to change the configuration for content in the Web space, relative to the document root. For example, the following configuration applies the HTTP header to any URL-path that begins in /store. It will apply to requests for https://yoursite.com/store and https://yoursite.com/store/file.html as well any other requests beginning with the /store string.
<Location /store> Header set X-UA-Compatible “IE=EmulateIE7” </Location>
Page Overrides
If you specify a default document compatibility mode using your Web server, you can override that setting by specifying a different document compatibility mode in a specific Web page. The mode specified within the Web page takes precedence over the mode specified by the server.
For more in-depth information on configuration options using directives, see <Location>, <Directory>, <Files>, and <VirtualHost>. For more information regarding the Header directive and how to use it in configuration sections, read the below documents.
Older Versions
The following links contain more information about how to add custom HTTP response headers to your site using older versions of Apache Web server.
Custom HTTP Response Headers and Other Web Servers
For more information about Windows Internet Explorer 8 document compatibility modes and Internet Information Services (IIS) Web server, read Implementing the META Switch on IIS.