Adding an http header site wide in php
I'm maintaining a web site for a non-profit organisation. I'm not the one who designed this web site, and I don't know the person who did it.
That said, I have an issue with IE9. I will eventually try to correct it, but meanhile just adding the X-UA-Compatible
header so IE9 turns to IE8 mode would work just fine.
In an asp.开发者_StackOverflow中文版net web site, I would add it in the web.config with the <customHeaders>
element (with IIS7).
Is there's a way to send this header for all file in a php web site, without editing all files?
Apache MOD_HEADERS, add the following to your root .htaccess file
<FilesMatch "\.(php|cgi|pl|htm)$">
Header set X-UA-Compatible IE=EmulateIE8
</FilesMatch>
This will set that header in the http header of all php, html, perl and cgi files, but I have had very bad experiences with the x-ua header, and found that it doesn't always work.
auto_prepend_file
and header()
, or configure it in your web server with e.g. Header
.
If you're using some kind of templating engine, you could just add <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" /> to the HEAD section of your template(s).
Otherwise, if you're including a single PHP file everywhere, you could add a header() call there (as long as it's before you output any content).
精彩评论