I have a multilanguage site:
www.example.com ->usa
www.example.com/index.php?country=FR
www.example.com/index.php?country=ES
$_GET['country'] -> echo countrytext;
if !_GET['country'] -> echo usa-text;
Somehow I made some mistakes in the past and I see pages in Google's index like this:
www.example.com/index.php?country=something-thats-not-in-my-DB
...it shows a blank template of course. How can I:
1) get rid of these 'non-existing' (but existing) pages.
2) prevent it that google indexes these non-existing pages again?
For 1) I am thinking of:
$countries = array("","CA","UK","AU","DE","CH","AT","NL","FR","BE","ES","IT");
if ($_GET['country']) {
$c = $_GET['country'];
} else {
$c = "";
}
if (!in_array($c,$countries)) {
$explode1 = explode(".", $_SERVER['HTTP_HOST']);
$domain = $explode1[0];
$explode2 = explode("?", $_SERVER['REQUEST_URI']);
$goodstring = $explode2[0];
$url = strtolower("http://" . $domain . ".example.com".$goodstring."");
header("HTTP/1.1 301 Moved Permanently");
header("Location: $url");
exit();
}
I am not sure if this is the right thing to do. For 2) I don't know what to do.