Friday 10 August 2012

The Right way to Redirect a Page

Well it seems like every time I do something new with my website, there is always something to learn. I'm in the process of rewriting the CMS I use for the how to's and examples on http://blueskyworkshop.com/topics/. I know I needed to use an HTTP header to forward pages. But after some additional reading, I learned what I was doing was not enough.



To tell a search engine like Google a page has moved, you have to send it a 301 Moved Permanently header. Then, the next time Google's spider reads the site, it will move the statistics associated with the page from the old location to the new one. This is done in PHP as follows:

<?php
// Permanent redirection
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.somacon.com/");
exit();
?>
Get the details from Somacon here. The post includes a number of examples for several different languages.



I should be able to confirm the older pages are no longer being referenced using Google Analytics. Anyway, I guess we will see in a few weeks.

No comments:

Post a Comment