Jump to content

How Do PHP Redirects Work?


Recommended Posts

I'm working on a site with an alias system that will redirect the browser to an aliased page if the non-aliased page is requested.


So if you go to mysite.com/about.php it will redirect to mysite.com/about.


I want to do this so google doesn't consider them 2 different pages (which it is now). Here is the redirect code-

header("HTTP/1.1 301 Moved Permanently");header("location: $newURL");exit();

I thought if I changed the header to a 301 header google would know this was a mistake and the new url was the actual page. However this is not the case.


So my question is-


Does this header information ever get passed back to the browser? Does the browser do the redirect or does PHP redirect (and the browser just updates the address bar)? Do I need to change the status on the resulting page to 301 instead of 200?

Link to comment
Share on other sites

Ok. That answers my question. So If I send a redirect to the browser with a 301 status it should know that the page has moved and not count it as 2 unique pages. I'll need to check with our SEO guys but that makes sense to me.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...