[英]How to redirect users to another page?
I need to redirect users that visit a certain page without providing specific parameters in a query string. 我需要重定向访问某个页面的用户,而不在查询字符串中提供特定参数。 How to redirect users to another page the right way?
如何以正确的方式将用户重定向到另一个页面? So that the search engines would not penalize me for it.
所以搜索引擎不会因此而惩罚我。
<?php
Header("HTTP/1.1 301 Moved Permanently");
Header("Location: http://www.new-url.com");
exit();
?>
The moved permanently is what helps with search engines. 永久移动是对搜索引擎的帮助。
if($condition){
header('Location: http://example.com');
exit();
}
will do it. 会做的。 Don't forget the
exit()
! 别忘了
exit()
!
<?php /* Redirect browser */ header("Location: http://www.google.com"); /* Make sure that code below does not get executed when we redirect. */ exit; ?>
Instead of http://www.google.com , you can write your own URL where you want to redirect your page. 您可以在自己的网址上编写自己的网址,而不是http://www.google.com 。
<?php
Header("HTTP/1.1 302 Moved Temporarily");
Header("Location: http://www.new-url.com");
exit();
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.