web.config下如何设置域名301重定向!
对于草根站长而言,我们在使用虚拟主机的时候,经常会遇到一个问题,就是301重定向,很多站长出于seo的考虑,经常需要把,abc.com重定向到www.abc.com
那么如何在web.config下 做301重定向呢?下面给出代码!
<?xml version="1.0"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="WWW Redirect" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^abc.com$" />
</conditions>
<action type="Redirect" url="http://www.abc.com/{R:0}"
redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
把以上代码,复制在TXT文档里面,然后重命名TXT文档为 web.config 上传到自己的根目录就行了!
本文地址:http://www.58q.org/artinfo/2169.html