301转向(301重定向,301跳转)是当用户或者搜索引擎向网站服务器发出浏览请求时,服务器返回http数据流中头信息(header)中的状态码的一种,表示本网页永久转移到另一个地址。
表示:将 yapocun.gotoip2.com转移到www.yapocun.com上
作用:网站域名发生变化,或者将多个域名的权重集中到一个域名上,有利于SEO和网址规范化。
在网站根目录下新建web.config
代码如下:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="301Redirect" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^yapocun\.gotoip2\.com$" />
</conditions>
<action type="Redirect" url="http://www.yapocun.com/{R:0}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
表示:将 yapocun.gotoip2.com转移到www.yapocun.com上