GlobalWarming Awareness2007

How this site about Globalwarming Awareness2007 do redirects SEO friendly using PHP

Every SEO knows that when a page's URL is changed we have to say to the client (also a spider is a client) what is the new URL.

The HTTP/1.1 protocol provides those headers to do this:

HTTP/1.1 301 Moved Permanently
Location: http://globalwarming-awareness2007.bloster.altervista.org/new-location.html

The 301 status code means that the page requested is Moved Permanently.

Location indicate the new page location.

Using PHP we can send an HTTP header using the header function.

Well, when I change an URL I update my option redirect in my MySQL table in this way:

<?php
// If option redirects exists then get it
$redirect = get_option('redirects');
// Add 1 item in the array $redirect.
// array index = old URL; value = new URL
$redirect[$_POST['old-url']] = $_POST['new-url'];
// Save the option
update_option('redirects', $redirect);
...

Therefore I save an array with a structure that look like this:

Array
(
    [globalwarming-awareness2007/globalwarming-awareness2007-directories-list.html] => globalwarming-awareness2007/directories-list.html
    ...
)

And when a page are requested:

<?php
$redirect = get_option('redirects');
if($redirect[$page_requested]){
	header("HTTP/1.1 301 Moved Permanently");
	header("Location: /index.php/".$redirect[$pag[1]]);
	header("Connection: close");
	exit();
}

That's all folks! :-)

Technorati tags:

My Awareness2007 - Index:

SEO Contest

GlobalWarming Awareness2007:

GlobalWarming Awareness2007