一、用php的header函数
也就是用php的header函数。php里的header函数的作用就是向浏览器发出由http协议规定的本来应该通过web服务器的控制指令,例如声明返回信息的类型(context-type: xxx/xxx),页面的属性(no cache, expire)等等。
用http头信息进行php重定向到另外一个页面的方法如下:
<?php
$url = "www.yaojinbu.com";
if (!empty($url))
{
header("http/1.1 303 see other"); //这条语句可以不写
header("location: $url");
}
?>
注意:"localtion:"后面有一个空格。
二、用html的meta标记
用html标记,就是用meta的refresh标记,举例如下:
<?php
if (!empty($url))
{
echo "<meta http-equiv=\"refresh\" content=\"0;url=$url\">";
}
?>
三、用javascript脚本函数
举例如下:
<?php
if (isset($url))
{
echo "<script language="javascript">";
echo "location.href='$url'";
echo "</script>";
}
?>
或者
<?php echo "<script>window.location =\"$url\";</script>";?>