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