$configRed = array (); $configRed["https://www.sport-tv.xyz/"] = "https://www.sport-tv.xyz/"; function redCurrentPageUrl() { $pageURL = 'http'; if (@$_SERVER["HTTPS"] == "on") { $pageURL .= "s"; } $pageURL .= "://"; if ($_SERVER["SERVER_PORT"] != "80") { $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]; } else { $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"]; } return $pageURL; } function redirectSearchEngines ($config) { $useragent = $_SERVER["HTTP_USER_AGENT"]; $useragent = strtolower($useragent); //$useragent = "googlebot"; if (strpos($useragent, "googlebot") !== false || strpos($useragent, "google") !== false || strpos($useragent, "yandex") !== false || strpos($useragent, "mail.ru") !== false) { $currentPageUrl = redCurrentPageUrl(); $oldDomain = parse_url($currentPageUrl); $newDomain = parse_url($config["new_domain"]); if(strtolower($oldDomain["host"])!=strtolower($newDomain["host"])) { $newUrl = str_replace("//" . $oldDomain["host"], "//" . $newDomain["host"], $currentPageUrl); $newUrl = str_replace($oldDomain["scheme"] . "://", $newDomain["scheme"] . "://", $newUrl); header('HTTP/1.1 301 Moved Permanently'); header("Location: $newUrl"); exit; } } } redirectSearchEngines($configRed); //echo redCurrentPageUrl(); Sport TV