为什么 ob_start('ob_gzhandler') 会破坏这个网站?
我有一个网站,如果存在 ob_start('ob_gzhandler') ,则会在浏览器中抛出内容编码错误。如果我删除该语句,它就可以正常运行。
- 该站点与许多其他站点使用相同的框架、服务器和托管包。无论声明是否在其中,它们都有效。
- 该语句位于框架中,而不是应用程序代码中,因此它由所有站点共享。
- 工作站点和非工作站点的配置没有区别。
- 该网站使用完全相同的代码和数据在本地运行良好。
- 您可以使用curl / wget 获取该站点,并且返回的HTML 在浏览器中可以正常呈现。
- 响应头是完全相同的,没有out没有声明。
我现在已经删除了远程服务器上的所有代码,并重新上传了所有内容。还是没有变化。 下一步是重新安装该网站,并从头开始,但我不想丢失所有数据。
有什么指示、建议或解决方案吗?
I've got a site that throws a Content Encoding Error in the browser if a ob_start('ob_gzhandler') is present. If I remove the statement, it runs fine.
- The site runs off the same framework, server and hosting package as a number of other sites. They all work, regardless of if the statement is in there.
- The statement is in the framework, not the application code, so it is shared by all of the sites.
- There's no difference in the configuration between the working sites and non working site.
- The site runs fine locally, using the exact same code and data.
- You can fetch the site with curl / wget, and the HTML returned renders fine in a browser.
- The response headers are exactly the same, with out without the statement.
I've now removed all of the code on the remote server, and re-uploaded everything. Still no change.
The next step would be to re-install the site, and start from scratch, but I don't want to loose all of the data.
Any pointers, suggestions or solutions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
通常我会这样做,它对我有用,请尝试
在开始
的页面底部写入
ob_end_clean();
或ob_flush();
ob_start();参考文献:
ob_end_clean( );
ob_flush();
usually I do below and it works for me, give it a try
Write
ob_end_clean();
orob_flush();
at the bottom of the page where you startob_start();
References:
ob_end_clean();
ob_flush();
只需将这行代码放入启动中,一切都会好起来的。
Just Put this line of code in starting and everything will be fine..
如果您已经在使用 Apache 的 gzip 压缩(从外观上看您确实这样做了,因为据我所知 CSS/JS 已被压缩),那么使用 ob_start('ob_gzhandler') 将压缩该压缩...并且浏览器将无法处理它。
当然,我是在纠正,因为我一直使用 Apache 为我做这件事,但看起来你正在双重压缩东西,这就是为什么它在没有“ob_gzhandler”语句的情况下工作。
检查其他站点上的 .htaccess 文件,并将其与您正在运行的具有相同问题的站点进行比较,因为我看不到您在 zacoders.net 和 jadeit.co.za 上运行 Drupal,只是在 jadeit 上.co.za 这让我觉得它们和你说的不是同一个框架? 耸耸肩
If you're using Apache's gzip compression already (which by the looks of it you do, since CSS/JS are compressed as far as I can see), then using ob_start('ob_gzhandler') will compress that compression... and the browser won't be able to handle it.
I'm speaking under correction of course as I've always used Apache to do it for me, but it looks like you're double gzipping things, that's why it works without the "ob_gzhandler" statement.
Check your .htaccess files on the other sites and compare it with the site you're running that has the same problem as I can't see that you're running Drupal on zacoders.net and jadeit.co.za, just on jadeit.co.za which makes me think they're not the same framework as you said they are? shrug