PHP页面跳转到另一个页面的三种方法

原创 2017-01-03 17:02:41 341
摘要:一、用HTTP头信息[size=3]<?php header("Location:[url]http://php.itcast.cn/[/url]");[/size]上面是302跳转,从seo角度,更喜欢下面的这种301跳转[size=3]<?php header("HTTP/1.1 301 Moved Permanently

一、用HTTP头信息

191321ak6ujxi7q7h16dp8.jpg.thumb.jpg

[size=3]<?php
header("Location:[url]http://php.itcast.cn/[/url]");[/size]

上面是302跳转,从seo角度,更喜欢下面的这种301跳转

191321khahcrl84umacg98.jpg.thumb.jpg

[size=3]<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location:[url]http://php.itcast.cn/[/url]");[/size]


二、用HTML标记

用HTML标记,就是用META的REFRESH标记,举例如下:

191322cj20on0oz4w7m2xy.jpg.thumb.jpg

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


三、用JAVASCRIPT脚本来实现

191323d8eew28kurwdtw81.jpg.thumb.jpg

[size=3]<?php
$url="http://php.itcast.cn";
echo "<script LANGUAGE=’Javascript’>;
echo "window.location.href='$url'";
echo "</script>";
?>[/size]


发布手记

热门词条