CodeIgniter项目给出303 /压缩错误

时间:2010-03-13 13:38:53

标签: php apache codeigniter

尝试为本地开发(LAMP堆栈)设置基于CodeIgniter的项目,并且一旦所有配置文件都更新(意味着我成功地为CodeIgniter创建了有意义的引导错误),我在浏览器中出现此错误:

  • 错误330(net :: ERR_CONTENT_DECODING_FAILED):未知错误。
  • 火狐
    内容编码错误:您尝试查看的页面无法显示,因为它使用了无效或不受支持的压缩形式。

使用wget获取文件工作正常,没有错误,我得到了我期待的内容。不确定这是CI和服务器的问题,还是项目的奇怪之处。 以前有人见过这个吗?

4 个答案:

答案 0 :(得分:10)

CodeIgniter似乎有自己的gzipping输出方法(为什么,我不知道,但我对CI不是很熟悉。)

根据this forum entry,当PHP错误消息搞砸了压缩内容时,可能会发生这样的错误。调整error_reporting到E_ALL ^ E_NOTICE就可以了。

更新:似乎还有CI配置设置:

$config['compress_output'] = FALSE;

答案 1 :(得分:5)

不确定我的评论在这里是否有价值,但我有一个类似的问题,我想与您分享,谁知道它可以帮助你们中的一些人。

对于我的项目,我在CI配置文件中激活了GZIP:

$config['compress_output'] = TRUE;

在配置文件中,很好地说:

| Enables Gzip output compression for faster page loads.  When enabled,
| the output class will test whether your server supports Gzip.
| Even if it does, however, not all browsers support compression
| so enable only if you are reasonably sure your visitors can handle it.
|
| VERY IMPORTANT:  If you are getting a blank page when compression is enabled it
| means you are prematurely outputting something to your browser. It could
| even be a line of whitespace at the end of one of your scripts.  For
| compression to work, nothing can be sent before the output buffer is called
| by the output class.  Do not 'echo' any values with compression enabled.
|
*/

启用压缩后,“不要'回显'任何值。”在这里非常重要。

但是,我的函数需要为我的Ajax调用回显一个json编码的数组。

为了解决这个问题,我在“echo”之后添加了“exit”功能。

    echo json_encode($arr_ajaxResults);
    exit();

现在,通过此输入,我不再面临“内容编码”错误。

我希望它可以帮助那些有同样问题的人。

答案 2 :(得分:0)

对于IIS用户,检查PHP Manager日志中的错误会很有用。

对我来说,错误是文件写入权限被拒绝。必须授予必要的权限。

答案 3 :(得分:0)

我的解决方案是:

文本编辑通常使用ascii编码,我用notepad ++打开文件并将页面编码更改为:utf-8 without BOM。现在页面运行良好。