GoDaddy Windows 主机启用Gzip压缩修改Web.config文件代码
以本blog为例:(Godaddy的Windows主机,IIS7,使用Wordpress程序)
一、先检查你网站的根目录是否已经有web.config文件
1、 如果你的根目录没有web.config文件,那么就自己新建一个,内容如下:
1 2 3 4 5 | <configuration> <system.webServer> <urlCompression doStaticCompression=”true” doDynamicCompression=”true” /> </system.webServer> </configuration> |
2、 如果你的根目录已经有web.config文件,请在“”
的上一行加上
1 2 3 | <system.webServer> <urlCompression doStaticCompression="true" doDynamicCompression="true" /> </system.webServer> |
分享下我的web.config
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <defaultDocument> <!-- Set the default document --> <files> <remove value="index.php" /> <add value="index.php" /> </files> </defaultDocument> <httpErrors errorMode="Detailed"/> <rewrite> <rules> <rule name="wordpress" patternSyntax="Wildcard"> <match url="*" /> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> </conditions> <action type="Rewrite" url="index.php" /> </rule> </rules> </rewrite> </system.webServer> <system.webServer> <urlCompression doStaticCompression="true" doDynamicCompression="true" /> </system.webServer> </configuration> |
二、检查gzip功能是否已经开启
检测地址1:http://tool.chinaz.com/Gzips/
检测地址2:http://www.whatsmyip.org/http-compression-test/
文章参考:crazyfeng.