在php中添加http标头网站 [英] 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.
那就是说,IE9有问题。我最终会尝试纠正它,但意味着只需添加 X-UA-Compatible
标题,以便IE9转向IE8模式就可以了。
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.
在asp.net网站上,我会在web.config中添加< customHeaders>
元素(使用IIS7)。
In an asp.net web site, I would add it in the web.config with the <customHeaders>
element (with IIS7).
有没有办法在php网站上为所有文件发送此标题,而不编辑所有文件?
Is there's a way to send this header for all file in a php web site, without editing all files?
推荐答案
Apache MOD_HEADERS,将以下内容添加到根目录.htaccess文件
Apache MOD_HEADERS, add the following to your root .htaccess file
<FilesMatch "\.(php|cgi|pl|htm)$">
Header set X-UA-Compatible IE=EmulateIE8
</FilesMatch>
这将在所有php,html,perl和cgi文件的http标头中设置该标头,但是我对x-ua标头有过非常糟糕的体验,并发现它并不总是有效。
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.
这篇关于在php中添加http标头网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!