php杂谈【基础篇】之_14.PHP页面跳转

来源:互联网 发布:手机java游戏 网站 编辑:程序博客网 时间:2024/06/06 12:55

**

php杂谈【基础篇】之_14.PHP页面跳转

**

一、用HTTP头信息

这里写图片描述

这里写图片描述

1.  [size=3]<?php2.  header("Location:[url]http://php.itcast.cn/[/url]");[/size]上面是302跳转,从seo角度,更喜欢下面的这种301跳转3.  [size=3]<?php4.  header("HTTP/1.1 301 Moved Permanently");5.  header("Location:[url]http://php.itcast.cn/[/url]");[/size]

二、用HTML标记
这里写图片描述

6.  [size=3]<?php  if (!isset($url)) exit;?>7.  <html>8.  <head>9.  <meta http-equiv="content-Type" content="text/html; charset=UTF-8" />10. <meta http-equiv="refresh" content="0; url=<?php echo $url;?>>11. </head>12. <body>13. </body>14. </html>[/size]

三、用JAVASCRIPT脚本来实现

这里写图片描述

15. [size=3]<?php16. $url="http://php.itcast.cn";17. echo "<script LANGUAGE=’Javascript’>;18. echo "window.location.href='$url'";19. echo "</script>";20. ?>[/size]
阅读全文
0 0