在iis7里面,你可以通过地址重写(URL Rewrite )来解决这个问题。在web.config里加入如下规则,所有用户访问http://iis7URL.com将会自动跳转到http://www.iis7URL.com

<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="WWW Redirect" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^contoso.com$" />
</conditions>
<action type="Redirect" url="http://www.contoso.com/{R:0}" 
redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

一个很重要事就是要使用“Permanent”(永久)定向。这样做很有帮助的是,任何人链接你的网站是使用的非www地址时,直接使搜索引擎的机器人在抓取作为永久移动的链接。新的url将会被定义为正确的地址,因此旧的非www地址将不会被索引。

一棵树认为:把网站域名(带www和非www)301重定向(资源永久重定向)到某一个域名(如上面案例,把非www地址永久重定向到带www上,有助于网站SEO优化。个人愚见,欢迎批评或参考。

本文地址:http://www.cnblogs.com/atree/archive/2010/09/13/IIS7-URL-Rewrite-Config.html

相关文章:

  • 2022-12-23
  • 2021-10-17
  • 2022-12-23
  • 2021-05-17
  • 2021-11-09
  • 2021-07-14
  • 2022-01-13
  • 2022-12-23
猜你喜欢
  • 2021-12-20
  • 2022-01-22
  • 2022-12-23
  • 2022-12-23
  • 2021-08-03
相关资源
相似解决方案