我正在将项目转移到新生产服务器时遇到问题。PHP 应用程序的 HTML 输出没有被 Apache mod_deflate 模块压缩。其他资源,如样式表和 javascript 文件,甚至与 PHP 输出具有相同内容类型 (text/html) 的 html 页面,都被压缩了!
项目在 .htaccess 中使用以下规则(来自 HTML5 样板):
<IfModule mod_deflate.c> # 对损坏的标头强制放气 developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping/ <IfModule mod_setenvif.c> <IfModule mod_headers.c> SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~ -]{4,13}$ HAVE_Accept-Encoding RequestHeader 附加 Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding </IfModule> </IfModule> # HTML、TXT、CSS、JavaScript、JSON、XML、HTC: <IfModule filter_module> 过滤声明压缩 FilterProvider COMPRESS DEFLATE resp=Content-Type $text/html FilterProvider COMPRESS DEFLATE resp=Content-Type $text/css FilterProvider COMPRESS DEFLATE resp=Content-Type $text/plain FilterProvider COMPRESS DEFLATE resp=Content-Type $text/xml FilterProvider COMPRESS DEFLATE resp=Content-Type $text/x-component FilterProvider COMPRESS DEFLATE resp=Content-Type $application/javascript FilterProvider COMPRESS DEFLATE resp=Content-Type …