CodeIgniter项目给出303 /压缩错误

Tim*_*tle 7 php apache codeigniter

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

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

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

Pek*_*ica 10

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

根据此论坛条目,当PHP错误消息搞砸压缩内容时,可能会发生此类错误.调整error_reporting E_ALL ^ E_NOTICE就可以了.

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

$config['compress_output'] = FALSE;
Run Code Online (Sandbox Code Playgroud)


You*_*sef 5

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

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

$config['compress_output'] = TRUE;
Run Code Online (Sandbox Code Playgroud)

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

| 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.
|
*/
Run Code Online (Sandbox Code Playgroud)

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

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

为了解决这个问题,我在"echo"之后添加了"exit"函数到函数中.

    echo json_encode($arr_ajaxResults);
    exit();
Run Code Online (Sandbox Code Playgroud)

现在,通过此输入,我不再面临"内容编码"错误.

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