最近很多初学者提到,不知道PHP如何做301重定向,有哪几种方式?
<?PHP
Header("HTTP/1.1 301 Moved Permanently");
Header("Location: https://www.xiaobinblog.com");
?>
实例应用完整跳转代码:
<?PHP
$the_host = $_SERVER['HTTP_HOST'];
$request_uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
if($the_host == 'xiaobinblog.com')
{
header('HTTP/1.1 301 Moved Permanently');
header('Location: https://www.xiaobinblog.com'.$request_uri);
}
?>
本文来自投稿,不代表本站立场,如若转载,请注明出处:https://www.xiaobinblog.com/1012.html
发表评论