zoukankan      html  css  js  c++  java
  • 301重定向

    301错误主要是域名更换后,搜索引擎还在使用你原有的域名地址访问你的网站,如果搜索引擎爬取的时候得到的是一个301错误,那么搜索引擎就知道你已经更换了域名,下次就会使用新域名来索引你的网站,当然你要告诉搜索引擎你的新域名是什么

    【引用百度拉】

    //需要在webconfig配置
     <system.webServer>
        <handlers>
          <add name="301html" path="*.html" verb="*" type="System.Web.UI.PageHandlerFactory" resourceType="Unspecified" preCondition="integratedMode" />
       
        </handlers> </system.webServer>
    
    //修改Global.asax文件
    
      void Application_BeginRequest(object sender, EventArgs e)
        {
            if (HttpContext.Current.Request.RawUrl.Contains("123.html"))//旧页面
            {
                Response.StatusCode = 301;
                Response.Redirect("http://www.baidu.com");//跳转地址
                Response.End();
            }
        }
        
    View Code
    上面的方式似乎不对,是以前的下面是 新的可用站长工具测试 返回的状态码
    
       string url = "http://www.baidu.com/";
       Response.StatusCode = 301;
       Response.AppendHeader("Location", url); //这个才是重点
    

      

  • 相关阅读:
    mybatis连接MySQL8.0出现的问题
    zqsb项目中发现没有getMSSVideoList
    idea快速实现接口的方法
    鸟枪换炮---IDEA
    IDEA的使用---常用的快捷键
    MQ消息队列
    token的主要用法?
    oracle中游标的使用
    乐观锁和悲观锁
    分布式系统的事务控制
  • 原文地址:https://www.cnblogs.com/LoveTX/p/4173419.html
Copyright © 2011-2022 走看看