1

I want to set some headers just for MSIE using apache configuartion file. How can i set the condition for that ?

# better website experience for ie users
<IfModule mod_headers.c && MSIE> # && MSIE is just exmple. WRONG
    Header set X-UA-Compatible "IE=Edge,chrome=1"
    # mod_headers can't match by content-type, but we don't want to send this header on *everything*...
    <FilesMatch "\.(js|css|gif|png|jpe?g|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|ico|webp|appcache|manifest|htc|crx|oex|xpi|safariextz|vcf)$" >
        Header unset X-UA-Compatible
    </FilesMatch>
</IfModule>

Apache 2.2

sysadmin1138
  • 133,124
  • 18
  • 176
  • 300

1 Answers1

2

You have to check the browser first, and set an environment variable. Then, the environment variable becomes the condition upon which you can act, by setting the header or – should you wish to – do other stuff. Here is an example:

BrowserMatch ".*MSIE.*" IE_browser=yes
Header set X-UA-Compatible "IE=Edge,chrome=1" env=IE_browser
<FilesMatch "\.(js|css|gif|png|jpe?g|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|ico|webp|appcache|manifest|htc|crx|oex|xpi|safariextz|vcf)$" >
    Header unset X-UA-Compatible
</FilesMatch>
pino42
  • 915
  • 5
  • 11
  • for ie11, you'll need to use "Trident", but otherwise, this works great. ref - http://www-01.ibm.com/support/docview.wss?uid=swg21661248 – chrismarx Jan 28 '15 at 21:30