301重定向代码分享

一般跳转有三种,通过asp或php程序,页面中meta和js跳转。

其中,meta和js跳转都属于302跳转,301重定向是网页更改地址后对搜索引擎友好的最好方法,只要不是暂时搬移的情况,都建议使用301来做转址。

以下是一些我整理的代码:
asp:

  1. <%   
  2. Response.Status="301 Moved Permanently"  
  3. Response.AddHeader "Location","http://www.9enjoy.com"  
  4. %>  

php:

  1. <?   
  2. Header( "HTTP/1.1 301 Moved Permanently" ) ;   
  3. Header( "Location: http://www.9enjoy.com" );   
  4. ?>  

asp.net

  1. <script runat="server">   
  2. private void Page_Load(object sender, System.EventArgs e)   
  3. {   
  4. Response.Status = "301 Moved Permanently";   
  5. Response.AddHeader ("Location","http://www.9enjoy.com");   
  6. }   
  7. </script>  
  1. da shang
    donate-alipay
               donate-weixin weixinpay

发表评论↓↓