【发布时间】:2016-07-12 16:35:44
【问题描述】:
我想为某些页面禁用 GZip。我的.htaccess 中有这个,但在访问dashboard/index 时它仍然会打开 GZip (Content-Encoding: gzip)。
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI /dashboard/index no-gzip dont-vary
我尝试添加 Header set MyHeader %{REQUEST_URI} 以查看 Request_URI 是什么,但它给出了内部服务器错误。
我还尝试了正则表达式dashboard/index、dashboard/index.*、"/dashboard/index" 等,并尝试了SetEnvIfNoCase REQUEST_URI ...,但 GZip 仍然打开。
如果我评论 #AddOutputFilterByType,则 GZip 将被关闭。
我正在使用 Apache 2.4.16、Yii 2.0.7、PHP。我在生产中使用 FPM,所以apache_setenv() 不可用。
【问题讨论】:
-
我能够使用
Header set myHeaderName "%{REQUEST_URI}e"输出带有请求 URI 的标头,这会产生标头myHeaderName: /project/web/dashboard/index。 GZip 仍处于开启状态。
标签: apache .htaccess gzip setenvif