如何将用户重定向到另一个页面?

问题描述:

我需要重定向访问某个页面的用户,而无需在查询字符串中提供特定参数。如何以正确的方式将用户重定向到其他页面?所以搜索引擎不会因此而惩罚我。如何将用户重定向到另一个页面?

+6

@Col:看起来Daniel A. Lemming在下面提供了一个很好的答案。 – 2011-02-01 18:58:38

+0

@罗伯特哈维你不能确定 – 2011-02-02 06:19:48

<?php 
    Header("HTTP/1.1 301 Moved Permanently"); 
    Header("Location: http://www.new-url.com"); 
    exit(); 
?> 

永久移动是什么帮助搜索引擎。

if($condition){ 
header('Location: http://example.com'); 
exit(); 
} 

会做到这一点。别忘了exit()

+0

搜索引擎? – Shoe 2011-02-01 15:41:06

<?php 
    Header("HTTP/1.1 302 Moved Temporarily"); 
    Header("Location: http://www.new-url.com"); 
    exit(); 
?> 

<?php 
 
/* Redirect browser */ 
 
header("Location: http://www.google.com"); 
 
    
 
/* Make sure that code below does not get executed when we redirect. */ 
 
exit; 
 
?>

相反的http://www.google.com,要驳你的页面,您可以编写自己的网址。