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. ?>