使用IIS禁用单个php文件的Gzip压缩 [英] Disable Gzip compression for single php file with IIS

查看:225
本文介绍了使用IIS禁用单个php文件的Gzip压缩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在互联网(PHP与IIS)上似乎不太常见的配置,到目前为止我还没能找到解决我问题的方法。

I have a configuration that doesn't seem too common on the Internets (PHP with IIS), and so far I have not been able to find a solution for my problem because of this.

基本上当我在我的php页面上发送手册404标题时:

Basically when I'm sending a manual 404 header on my php page:

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

问题是我总是得到编码错误,我已经确定这与编码有关gzip正在启用。

The problem is that I then always get encoding errors, which I've determined has something to do with gzip being enabled.

当我卷曲 - 压缩时,我得到:

When I curl with --compressed I get:

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

是否可以为这一页禁用压缩?或者是否有其他解决方案,我错过了?我不想为整个站点禁用压缩。

Is it possible to disable compression just for this one page? Or is there some other solution for this that I'm missing? I don't want to disable compression for the entire site.

推荐答案

这很简单,只需使用ini set,如下所示:

This is simple, just use the ini set like so:

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

这很简单。

这篇关于使用IIS禁用单个php文件的Gzip压缩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆