不用插件直接启动WordPress的Gzip网页压缩

本文是在类unix系统(freebsd)下通过Apache服务器来实现的,若你的web服务器不是apache,本文可能不适用。
Apache服务器下可以利用.htaccess文件启动Gzip网页压缩,这方法是通过阿帕契(Apache)的Enabling Compression来达到。请通过FTP将您的.htaccess文件下载回来,如果没有请用记事本建立一个,储存时类型请选择所有文档,然后档名输 入.htaccess即可。在.htaccess文件中请加入以下语法,然后保存上传覆盖即可。
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
<IfModule mod_deflate.c>
# Insert filters
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-httpd-fastphp
AddOutputFilterByType DEFLATE image/svg+xml

# Drop problematic browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

# Make sure proxies don’t deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>
现在,你可以打开以下网址来测试是否成功了!
下面是几个测试网站是否启用gzip压缩的网址:

http://tool.chinaz.com/Gzips/Default.aspx

http://gzip.zzbaike.com/

http://www.websiteoptimization.com/services/analyze/

本文转摘自AioBox不用插件直接启动WordPress的Gzip网页压缩

原文链接:,转发请注明来源!

发表评论