gpt4 book ai didi

php - 使用 IIS 禁用单个 php 文件的 Gzip 压缩

转载 作者:可可西里 更新时间:2023-11-01 00:16:42 25 4
gpt4 key购买 nike

我有一个在 Internet 上似乎不太常见的配置(带有 IIS 的 PHP),因此到目前为止我还没有找到解决我的问题的方法。

基本上当我在我的 php 页面上发送手动 404 header 时:

header('HTTP/1.0 404 Not Found');

问题是我总是遇到编码错误,我确定这与启用 gzip 有关。

当我使用 --compressed 进行 curl 时,我得到:

HTTP/1.1 404 Not Found
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Length: 3560
Content-Type: text/html
Content-Encoding: gzip
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Vary: Accept-Encoding
Server: Microsoft-IIS/6.0
Set-Cookie: PHPSESSID=b0ueqhtc3o4p7m2luqss170fr3; path=/
Date: Mon, 11 Jul 2011 16:15:40 GMT

curl: (61) Error while processing content unencoding: invalid code lengths set

是否可以仅针对这一页禁用压缩?还是我缺少其他解决方案?我不想对整个站点禁用压缩。

最佳答案

这很简单,只需像这样使用 ini 集:

<?php 
if(ini_get('zlib.output_compression')){
ini_set('zlib.output_compression', 'Off');
}
header('HTTP/1.0 404 Not Found');
?>

就这么简单。

关于php - 使用 IIS 禁用单个 php 文件的 Gzip 压缩,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6653940/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com