我如何设置为只有我们的国家和 google 机器人可以看到我的网站?
How can i set to only our country and google bot can see my web site?
我在 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();
}
}
但我可以看到此页面包含来自其他国家/地区的代理网站。我只想让我的国家 IP 和 googlebot 看到这个页面。
您可能想试试:
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");
}
我在 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();
}
}
但我可以看到此页面包含来自其他国家/地区的代理网站。我只想让我的国家 IP 和 googlebot 看到这个页面。
您可能想试试:
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");
}