301重定向的几种方法

301重定向的几种方法

1、IIS新建网站来做301重定向

1、打开internet信息服务管理器,在欲重定向的网页或目录上按右键选择属性

2、选中“重定向到URL”

3、在对话框中输入目标页面的地址

4、切记,记得选中“资源的永久重定向”

5、当然,最后要点击“应用”

2、ASP.NET 中使用C#代码来做301重定向

    Response.Status = "301 Moved Permanently"; 
    Response.AddHeader("Location","http://www.hi1718.com");  
3、 Web.config 配置301重定向
    <configuration>
      <system.webServer>
        <rewrite>
          <rules>

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

写于2013-12-21

posted @ 2016-12-20 11:49  青空feng  阅读(581)  评论(0编辑  收藏  举报