Header set MyHeader "I'm Set!"
如果我转到没有默认索引文件的目录(http://example.com/test/),并查看网络活动(在本例中为Chrome),我可以看到正在发送标头.如果我转到PHP文件(http://example.com/test/test.PHP),则不会发送标头.
我创建了一个index.html(简单地以< pre> Hi作为内容)并将其发送.我将文件名更改为.PHP,没有标题.如果我将orignal test.PHP更改为test.html,它会输出看似垃圾的代码,并发送标头.如果我将test.PHP更改为test.png,我会得到一个损坏的图像图标,并且会发送标题.
因此,如果没有超出上述范围的mime类型和文件扩展名进行测试,则只显示.PHP文件(合法或其他)设置为不具有.htaccess规则或特别是mod_headers指令.但我不知道如何测试这个,因为它是一个共享服务器,我没有httpd.conf访问权限.
我也尝试过:
<FilesMatch "\.(PHP)$"> Header set MyHeader "I'm Set!" </FilesMatch>
The default value of onsuccess may need to be changed to always under
the circumstances similar to those listed below. Note also that
repeating this directive with both conditions makes sense in some
scenarios because always is not a superset of onsuccess with respect
to existing headers:[…]
You’re modifying or removing a header generated by a CGI script,in which case the CGI scripts are in the table corresponding to always and not in the default table.
最初的问题(或许更好的解释)是在Bug 49308.