Apache if ie send some header

apache-2.2conditionalhttp-headersinternet explorer

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

Best Answer

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>