1

我将此代码添加到 opencart 系统上的 index.php 中。

if(!strstr(strtolower($_SERVER['HTTP_USER_AGENT']), "googlebot"))
{
    if($_SERVER["HTTP_CF_IPCOUNTRY"] =! 'UK')
    { 
       echo "You can not see this page.";
       die();
    }
}

但我可以看到这个页面有来自其他国家的代理网站。我只想让 My Country IP 和 googlebot 看到这个页面。

4

1 回答 1

1

您可能想尝试:

if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),'googlebot') !== false OR $_SERVER["HTTP_CF_IPCOUNTRY"] == 'UK') {
    echo "GoogleBot and UK users will see this";
}else{
    die("DENIED");
}
于 2015-10-11T21:48:02.030 回答