【发布时间】:2011-02-19 14:51:20
【问题描述】:
我有一个 Liquid Web VPS 帐户,我已确保 mod_deflate 已安装并正在运行/处于活动状态。
我曾经通过 PHP 压缩我的 css 和 js 文件,以及我的 PHP 文件本身...但是,我现在正尝试通过 mod_deflate 来执行此操作,它似乎对除 PHP 之外的所有文件都有效文件。 (Txt 文件可以正常工作,css、js、静态 HTML 文件,没有通过 PHP 文件生成。)我该如何解决这个问题?
(我使用了cPanel中“优化网站”下的“压缩所有内容”选项,它在主目录(不是public_html,比它高一级)中创建了一个.htaccess文件,其文本与“压缩”完全相同除了图像之外的所有内容”例如http://httpd.apache.org/docs/2.0/mod/mod_deflate.html)
.htaccess 文件:
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
<IfModule mod_setenvif.c>
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary
</IfModule>
<IfModule mod_headers.c>
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>
</IfModule>
【问题讨论】:
-
你能显示 htaccess 文件吗?
-
所以你压缩了两次数据?
-
@Gumbo - 不,我从 PHP 文件中删除了压缩,现在只依赖 mod_deflate。
标签: php .htaccess gzip httpd.conf mod-deflate