Mos*_*ini 6 php apache content-type http-headers
如何删除apache中的头内容类型?
以下代码不起作用
header_remove('content-type');
尝试
<?php
header('Content-Type:');
Run Code Online (Sandbox Code Playgroud)
这完全Content-Type从响应中删除了标头。和你一样,使用header_remove()没有做任何事情,Hereblur 的回答Content-Type: none让我在回应中留下了答案。
这取决于您拥有哪些 php.ini 指令,以及您使用的 PHP(CLI、CGI 等)。
这个答案基于 PHP 5.4,在 CGI 中运行。
在 php.ini 中注意:
default_mimetype = text/html
Run Code Online (Sandbox Code Playgroud)
这是默认值,PHP 发送为:
Content-Type: text/html
Run Code Online (Sandbox Code Playgroud)
如果你想摆脱它,你必须通过再次创建标题来删除默认值,然后你可以删除标题:
<?php
header('Content-Type: text/html');
header_remove('Content-Type');
Run Code Online (Sandbox Code Playgroud)
尝试这个。
header("content-type: none");
Run Code Online (Sandbox Code Playgroud)
我不知道为什么,但这对我有用。
我找不到任何关于此的参考资料。但它只是content-type为我删除了 from 标头。这可能是 apache 的 bug 或 PHP 的 bug。因此请尝试并谨慎使用。
| 归档时间: |
|
| 查看次数: |
5873 次 |
| 最近记录: |