Godaddy的Windows IIS7主机开启GZip_WordPress用web.config文件开启GZip

2010-10-04 | 夜光 | IT记录| 发表评论

Godaddy Windows主机 IIS7 默认是没开启GZIP功能的, 但是GZIP能压缩数据,可加快传输速度。

WordPress有个插件WP-Super-Cache,里面有个选项“Compress pages so they’re served more quickly to visitors.”如果勾选了则是通过程序生成.gz文件来开启GZIP,但Godaddy主机本身是支持GZip压缩输出的,不需要通过程序生成.gz文件开启

以下适用于Godaddy的windows虚拟主机,当然也适合别的本身支持开启gzip的windows主机。

利用web.config文件开启GZip方法:

把如下代码加入到web.config的configuration节点中,也就是在最后一个

</configuration>

上一行加上如下代码:

<system.webServer>
   <urlCompression doStaticCompression="true" doDynamicCompression="true" />
</system.webServer>

因为Godaddy主机本身是支持GZip压缩输出的,不需要通过程序生成.gz文件开启。

如果网站是WordPress,那么完整的根目录web.config文件如下:

<configuration>
  <system.webServer>
    <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>
		<rule name="WWW Redirect" stopProcessing="true">
              <match url=".*" />
                 <conditions>
                    <add input="{HTTP_HOST}" pattern="^www.boliquan.com$" />
                 </conditions>
              <action type="Redirect" url="http://boliquan.com/{R:0}"
                 redirectType="Permanent" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
<system.webServer>
   <urlCompression doStaticCompression="true" doDynamicCompression="true" />
</system.webServer>
</configuration>
本文标签: ,,
本文链接: http://boliquan.com/windows-wordpress-webconfig-gzip/
版权所有: 玻璃泉, 转载请注明本文出处。

6个评论

  1. 现在国内很多主机还不支持GZip

  2. @Firm
    即使不支持通过web.config文件开启,也可以使用插件生成.gz文件来开启的。

  3. 正准备搬去Godaddy,应该用得着

  4. @手机链 godaddy对wp-super-cache支持并不好吧…

  5. @auapple
    设置好了就行,没发现有什么问题~

  6. 不错,我一直这样用,感觉要快些

发表评论

您的昵称 *

您的邮箱 *

您的网站

icon_wink.gif icon_neutral.gif icon_mad.gif icon_twisted.gif icon_smile.gif icon_eek.gif icon_sad.gif icon_rolleyes.gif icon_razz.gif icon_redface.gif icon_surprised.gif icon_mrgreen.gif icon_lol.gif icon_idea.gif icon_biggrin.gif icon_evil.gif icon_cry.gif icon_cool.gif icon_arrow.gif icon_confused.gif icon_question.gif icon_exclaim.gif

Protected by WP Anti Spam