2

301跳转

header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.url.com' . $_SERVER['PHP_SELF']  . $request_uri);

 
加强版(有判断)

$the_host = $_SERVER['HTTP_HOST'];
$request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
if($the_host !== 'www.demo.com') {
    //echo $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
    header('HTTP/1.1 301 Moved Permanently');
    header('Location: http://www.demo.net' . $_SERVER['PHP_SELF']  . $request_uri);
}

青叶
1.5k 声望111 粉丝

一个phper