PHP header redirect 301 - what are the implications?

Andres SK picture Andres SK · Sep 6, 2011 · Viewed 107.1k times · Source

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.

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. 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.

Answer

Roel Veldhuizen picture Roel Veldhuizen · Sep 6, 2011

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 ;-)

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();