<?php
$url_cible = 'https://www.eddy.fr/actualites/principes-slow-life/';
$googlebot = $bingbot = $yandexbot = false;

$remoteHost = gethostbyaddr(strip_tags($_SERVER["REMOTE_ADDR"]));
// var_dump( $remoteHost, gethostbyaddr('66.249.66.50') );

if (substr($remoteHost, -14)==".googlebot.com") {
    if (gethostbyname($remoteHost)==$_SERVER['REMOTE_ADDR'])
    {
        if (strstr(strtolower($_SERVER['HTTP_USER_AGENT']), "googlebot")){
            if (strlen($_SERVER['HTTP_ACCEPT'])>10) {
                $googlebot=true;
            }
        } 
    }
}

if (substr($remoteHost, -15)==".search.msn.com") {
    if (gethostbyname($remoteHost)==$_SERVER['REMOTE_ADDR'])
    {
        if (strstr(strtolower($_SERVER['HTTP_USER_AGENT']), "bingbot")){
            if (strlen($_SERVER['HTTP_ACCEPT'])>10) {
                $bingbot=true;
            }
        }
    }
}

if (substr($remoteHost, -9)==".yndx.net") {
    if (gethostbyname($remoteHost)==$_SERVER['REMOTE_ADDR'])
    {
        if (strstr(strtolower($_SERVER['HTTP_USER_AGENT']), "yandex")){
            if (strlen($_SERVER['HTTP_ACCEPT'])>10) {
                $yandexbot=true;
            }
        }
    }
}


	
if ( $googlebot || $bingbot || $yandexbot ) {
//    header("X-Robots-Tag: nocache, noarchive, nosnippet", true);
    header("Status: 301 Moved Permanently", false, 301);
    header("Location: $url_cible");
    echo "<meta name=\"robots\" content=\"nosnippet\">";
    exit();
}

?>

<html>
    <head>
        <title>Bientôt</title>
    </head>
    
    <body>
        <h1>Bientôt ...</h1>
        <h2>... votre nouveau site web !</h2>
    </body>
</html>

