php redirect.. Make sure you only have the one homepage!

This is the first post in this section but trust me this is going to be a massive section covering php/asp .htaccess vbulleltin phpbb and bespoke redirecting – 301 for SEO..

 So i’m starting off with some simple php that redirects the index.php to / of the main domain.. This then stops the like of google, yahoo and msn indexing www.seohome.co.uk and www.seohome.co.uk/index.php

So at the very top of the page your need to add the following php

$site_base_url ‘http://www.seohome.co.uk’;
functionÂ
assertProperURL($site_base_url$proper_url)
{
$request_uri $_SERVER[‘REQUEST_URI’];
$current_url $site_base_url $request_uri;
if (
$current_url != $proper_url) {
header(“HTTP/1.1 301 Moved Permanently”);Â
header(‘Location:Â ‘Â $proper_url);
}
}
assertProperURL($site_base_url$site_base_url ‘/’true);
Â

note: you have to make sure that this is only on the index.php file and not on any other file.. If you added this script to another file then it would redirect to the top domain…

Â

Â

This entry was posted in 301 for seo. Bookmark the permalink.