apache CodeIgniter 项目给出 303/压缩错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2438517/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CodeIgniter Project Giving 303/Compression Error
提问by Tim Lytle
Trying to setup a CodeIgniter based project for local development (LAMP stack), and once all the config file were updated (meaning I successfully had meaningful bootstrap errors for CodeIgniter), I get this error in my browsers:
尝试为本地开发(LAMP 堆栈)设置一个基于 CodeIgniter 的项目,一旦所有配置文件都更新(意味着我成功地遇到了 CodeIgniter 的有意义的引导错误),我在浏览器中收到此错误:
- Chrome
Error 330 (net::ERR_CONTENT_DECODING_FAILED): Unknown error.
- Firefox
Content Encoding Error: The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression.
- 铬合金
错误 330 (net::ERR_CONTENT_DECODING_FAILED):未知错误。
- 火狐
内容编码错误:无法显示您尝试查看的页面,因为它使用了无效或不受支持的压缩形式。
Just using wget to fetch the file works fine, no errors and I get the content I'm expecting. Not sure if this is something with CI and the Server, or just something weird with the project. Has anyone seen this before?
只是使用 wget 来获取文件工作正常,没有错误,我得到了我期待的内容。不确定这是否与 CI 和服务器有关,或者只是与项目有关。有没有人见过这个?
回答by Pekka
CodeIgniter seems to have its own method of gzipping its output (Why, I don't know, but I'm not very familiar with CI.)
CodeIgniter 似乎有自己的 gzip 输出方法(为什么,我不知道,但我对 CI 不太熟悉。)
According to this forum entry, such an error can occur when PHP error messages screw up the compressed content. Adjusting error_reporting to E_ALL ^ E_NOTICEdid the trick there.
根据这个论坛条目,当 PHP 错误消息搞砸了压缩内容时,可能会发生这样的错误。调整 error_reporting 来解决E_ALL ^ E_NOTICE这个问题。
Update: There also seems to be a CI config setting:
更新:似乎还有一个 CI 配置设置:
$config['compress_output'] = FALSE;
回答by Youssef
Not sure if my comment is valuable here, but I had a similar issue that I want to share with you, who knows may be it can help some of you.
不确定我的评论在这里是否有价值,但我有一个类似的问题想与您分享,谁知道它可能对你们中的一些人有所帮助。
For my project, I have activated the GZIP in my CI config file:
对于我的项目,我在 CI 配置文件中激活了 GZIP:
$config['compress_output'] = TRUE;
In the config file it is well said that:
在配置文件中很好地说:
| 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.
|
*/
The "Do not 'echo' any values with compression enabled." is very important here.
“不要'回显'启用压缩的任何值。” 在这里非常重要。
However, my function needs to echo a json encoded array for my Ajax call.
但是,我的函数需要为我的 Ajax 调用回显一个 json 编码的数组。
In order to fix that, I have added the "exit" function after my "echo" into the function.
为了解决这个问题,我在“echo”之后添加了“exit”函数到函数中。
echo json_encode($arr_ajaxResults);
exit();
Now, with this input, I don't face no more the "Content Encoding" error.
现在,有了这个输入,我不再面临“内容编码”错误。
I hope it can help guys who have the same issue.
我希望它可以帮助有同样问题的人。
回答by user2336292
My solution is:
我的解决办法是:
text editors normaly use ascii codifications, I open the file with notepad++ and change the page codification to: utf-8 without BOM. And the page now is working good.
文本编辑器通常使用 ascii 编码,我用 notepad++ 打开文件并将页面编码更改为:utf-8 without BOM。现在页面运行良好。
回答by user2336292
For IIS users it would be useful to check the errors within the PHP Manager log.
对于 IIS 用户,检查 PHP 管理器日志中的错误会很有用。
For me the error was file write permission denied. Had to grant the necessary permissions.
对我来说,错误是文件写入权限被拒绝。必须授予必要的权限。

