php http 301 302 重定向 跳转

  • A+
所属分类:PHP学习

301、302 都是HTTP状态的编码,都代表着某URL发生了转移,不同之处在于:301 代表永久性转移(Permanently Moved),302 代表暂时性转移(Temporarily Moved)。用htaccess做301重定向很不错,不过需要apache、litespeed等的支持。如果是iis怎么办,可以用PHP重定向

header('HTTP/1.1 301 Moved Permanently'); //无此句则是302
header('Location: http://www.zxar520.com/');

也可简写为
header('Location: http://www.zxar520.com/',true,301);//据风吟说:此句是不标准的用法。

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: