加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

当文件是PHP时,mod_headers不发送头文件

发布时间:2020-12-13 14:00:50 所属栏目:PHP教程 来源:网络整理
导读:我将.htaccess文件设置为以下内容: Header set MyHeader "I'm Set!" 如果我转到没有默认索引文件的目录(http://example.com/test/),并查看网络活动(在本例中为Chrome),我可以看到正在发送标头.如果我转到php文件(http://example.com/test/test.php),则不会
我将.htaccess文件设置为以下内容:
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访问权限.

关于为什么apache会跳过发送php文件头的任何想法?

我也尝试过:

<FilesMatch ".(php)$">
     Header set MyHeader "I'm Set!"
 </FilesMatch>
这是运行CGI脚本时的预期行为.从最新的(2.4)版本的 the mod_headers docs:

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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读