简体   繁体   English

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

[英]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.

相关问题 如何将管理员重定向到特定页面并将用户重定向到另一个页面 - Laravel 8 jetstream - How to redirect Admin to a specific page and users to another - Laravel 8 jetstream 如何将未登录的用户重定向到登录页面并重定向到保存数据的另一个页面? - how to redirect non logged users to login page and redirect to another page with saved data? 将IE8用户重定向到另一个页面 - Redirect IE8 users to another page 如何将移动用户和PC用户重定向到另一个URL但位于同一网页中 - How to redirect mobile users and pc users to another url but are in the same web page 如何重定向到另一个页面? - how to redirect on another page? php成功响应后,如何将用户重定向到ajax中的另一个页面 - how can i redirect users to another page in ajax after success response from php 如果使用标题将用户重定向到另一个页面,如何使用通知用户表单提交错误 - How to use inform users of form submission errors if header is used to redirect the user to another page 如何将用户重定向到另一个域.htaccess - How to redirect users to another domain .htaccess 如何将用户重定向到他们自己的个人资料页面? - How to redirect users to their own profile page? 登录后如何将用户重定向到他们指定的页面? - How to redirect users to their specified page after logging in?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM