PHP 301 重定向的两种写法
方法一 (推荐)
<?php
header("Location: https://kakarot.net", true, 301);
exit();
?>
方法二
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: https://kakarot.net");
?>
- 注意:下面这种写法是错误的,虽然能实现同样的效果,但是没有声明是301重定向,搜索引擎会认为是302暂时重定向,如果你要做SEO的话,这是非常不友好的。
<?php
header("Location: https://kakarot.net");
?>