PHP头部重定向301 - 有什么影响? [英] PHP header redirect 301 - what are the implications?

查看:103
本文介绍了PHP头部重定向301 - 有什么影响?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 domain.com 。如果用户登录,它应自动加载 domain.com/option-X ,其中X是用户的预定义选择。

I have domain.com. If the user is logged in, it should load automatically domain.com/option-X where X is a predefined choice of the user.

因此,我在index.php的顶部执行此操作:

So, I do this at the top of index.php:

header("Location: /option-X"); 

但是,如果用户未登录,我只会自动选择第一个选项,如下所示:

But, if the user is not logged in, I just choose automatically the first option like this:

header("HTTP/1.1 301 Moved Permanently"); 
header("Location: /option-a"); 

所以,我有两个关于这样做的问题:

So, i have two questions regarding the implications of doing so:


  1. 由于搜索引擎抓取工具不会登录,他们总是会收到 domain.com/option-a - 是否影响他们它有一个301头?

  2. 执行这些重定向的服务器cpu负载是多少?我不知道如何进行测试。当前网站(没有重定向)每天的访问量约为10万次。

  1. Since the search engines crawlers won't be logged in, they will always get domain.com/option-a - does it affect them that it has a 301 header?
  2. What could be the server cpu load of doing those redirects? I don't know how to make a test out of it. The current site (which has no redirects) has about 100k daily visits.


推荐答案

的301将是搜索引擎将索引/选项-a而不是/选项-x。这可能是一件好事,因为/ option-x不可用于搜索索引,因此可能对索引产生积极影响。 - )

The effect of the 301 would be that the search engines will index /option-a instead of /option-x. Which is probably a good thing since /option-x is not reachable for the search index and thus could have a positive effect on the index. Only if you use this wisely ;-)

重定向后放置exit();停止脚本的其余部分执行

After the redirect put exit(); to stop the rest of the script to execute

header("HTTP/1.1 301 Moved Permanently"); 
header("Location: /option-a"); 
exit();

这篇关于PHP头部重定向301 - 有什么影响?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆