标签:
PHP实现301跳转的方法:
$theHost = $_SERVER[‘HTTP_HOST‘]; $theUrl = isset($_SERVER[‘REQUEST_URI‘])? $_SERVER[‘REQUEST_URI‘]:‘‘; $theUrl = strtolower($theUrl); if($theUrl == ‘/index.php‘) { $theUrl = ‘‘; } if($theHost != ‘www.test.com‘) { header(‘HTTP/1.1 301 Moved Permanently‘); header(‘Location:http://www.test.com‘.$the_url); }
将此代码放在*.php首行,或者放置在config.php中。
标签:
原文地址:http://www.cnblogs.com/izhengyang/p/5346914.html