See here:
http://www.seatkarma.com/search.php?query=Mary+Poppins
Redirects to:
http://www.seatkarma.com/search.php/Mary-Poppins
Here is the code that we are using to do it:
Code: Select all
if (strlen($_GET['query'])) {
$query = trim(strtr($_GET['query'], ' ', '-'));
header('Location: /search.php/'.urlencode($query), true, 301);
exit();
}
$query = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], 'search.php/') + 11);
$query = strtr($query, '_', ' ');
$query = strtr($query, '-', ' ');
$query = trim($query);
if (strlen($query) == 0) {
header('Location: /index.php?message=emptyQuery');
exit();
}
http://www.seatkarma.com/search.php/Mary-Poppins
has a duplicate at
http://www.seatkarma.com/search.php/Mary_Poppins
The search engines don't like duplicate content much, so we want to resolve this by permanently redirecting any requests for http://www.seatkarma.com/search.php/Search_Term
to http://www.seatkarma.com/search.php/Search-Term
Can this be done by modifying the code above somehow? Please advice. Thanks!