Hi all,
I have discovered that Google has indexed 2 urls for same page, one with a dash and one with a space (contains %20 in url in listings).
I need to do a 301 redirect within the php page to detect if the space version has been used and go to the correct dashed version.
I have tried to find the space, but its not finding it and redirecting:
Any ideas?PHP Code://array of possible space characters to search for
$space_array = array(" ","%20","\s");
// get page name
$name = clean($_GET['name']);
// replace dash for content purposes
$name2 = str_replace("-"," ",$name);
// replace spaces with dash for 301
$name3 = str_replace($space_array,"-",$name);
//if we find a space in url then do 301 to actual dashed page
if ( stristr($space_array,$name) ){
header('HTTP/1.1 301 Moved Permanently');
header("Location: http://www.mywebsite.co.uk/$name3-page.html");
die();
}




cheers

Bookmarks