Craig McCoy

Programmer / Developer & Zombie Survivalist

PHP Permanently Move A Page

Mar/2008 01

The proper way to move a page and have search engines properly find it is to use a 301 redirect. The 301 redirect tells the search engines that "this page has permanently moved". I am in the process of redirecting an entire website using 301 redirects, and I will post updates on the impact this has on the SEO and search engine placement on the site. The code to do a 301 redirect in php is as follows:

<?php

// Permanent redirection

header("HTTP/1.1 301 Moved Permanently");

header("Location: http://www.somacon.com/");

exit();
?>

Be sure you put the line : header("HTTP/1.1 301 Moved Permanently"); Because as I have recently discovered, just using the header location line does a 302 redirect instead of a 301.  A 302 redirect tells the search engines that "this page has temporarily moved".  So be sure you do this correctly if the page is permanently moving.

Tags: