Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

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>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.