php程序实现301重定向
< ?php $the_host = $_SERVER['HTTP_HOST']; $the_url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; $the_url = strtolower($the_url); if($the_url=="/index.php") { header('HTTP/1.1 301 Moved Permanently'); header('Location:http://www.yonghappy.com'); } if($the_url !=="/index.php") { header('HTTP/1.1 301 Moved Permanently'); header('Location:http://www.yonghappy.com'.$the_url); } ?>
将其中的域名换成自己的就可以了,这段代码应该可以在所有支持PHP的空间完美运行