php header函數實現301跳轉

php 301跳轉的代碼,主要是用header函數實現轉。

 PHP 301跳轉的小代碼
  1. <?php     
  2.  $the_host = $_SERVER['HTTP_HOST'];  
  3.  $request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';  
  4.  if($the_host !== 'www.jbxue.com')  
  5.  {  
  6.      //echo $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];  
  7.     header('HTTP/1.1 301 Moved Permanently');  
  8.     header('Location: http://www.jbxue.com' . $_SERVER['PHP_SELF']  . $request_uri);  
  9.  }  
  10. ?>  
相關文章
相關標籤/搜索