php实现页面跳转的三种方法
1.第一种:<?php
header("Location: http://www.vbzh.com/forum");
?>
2.第二种:
和javascrīpt结合起来
echo "<scrīpt language=javascrīpt>";
echo "location.href='www.XXX.com';";
echo "</scrīpt>";
3.第三种:
echo("<meta http-equiv='refresh'content=0;URL='join.html'>");
******************************************************************************************************************
php页面跳转
php只有一种方法,利用JavaScript的window.location是一种方法,利用html的meta的Refresh是一种方法。
代码
1. php的header
Header("Location: http://www.dreamdu.com/xhtml/");
2. JavaScript的window.location
echo "<script>window.location=\"http://www.dreamdu.com/xhtml/\";</script>";
3. HTML的meta的refresh
echo "<meta http-equiv=\"refresh\" content=\"0; url=http://www.dreamdu.com/\" />";
当时使用php的header方法是也可以为跳转定义html状态码
比如:
Header("HTTP/1.1 301 Moved Permanently");Header("HTTP/1.1 307 Temporary Redirect");Header("HTTP/1.1 303 See Other");
html状态码,可以在http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html里查看
如果是永久性的重定向,考虑到seo可以使用下面代码
Header("HTTP/1.1 301 Moved Permanently");Header("Location: http://www.dreamdu.com/xhtml/");
页:
[1]