wordpress 页面gzip(不用插件)

/ 0评 / 0

利用.htaccess启动Gzip网页压缩

此方法是通过Apache的Enabling Compression,在你服务器站点的根目录下将.htaccess文件下载回来,要是没有就vim创建一个.htaccess文件中写入,然后储存上传。

<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/

百度已收录

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

来来来,看看你是不是一个人。 *