我只想从我的国家访问我的网站,我想通过谷歌和 Facebook 访问我的网站。所以我查看了这些页面:
https://developers.facebook.com/docs/sharing/best-practices#crawl https://support.google.com/webmasters/answer/1061943?hl=en 我写了这个 php 代码:
<?php
$agent = $_SERVER['HTTP_USER_AGENT'];
if (!preg_match("/facebook/", $agent) && !preg_match("/bingbot/", $agent) && !preg_match("/Googlebot/", $agent) && $agent != 'Facebot')
{
$country = geoip_country_code_by_name($_SERVER['REMOTE_ADDR']);
if($country != 'AZ')
{
$error = 'Sorry, we can only serve to Azerbaijan!';
include('error.php');
die;
}
}
?>
它适用于脸书。但是当我想用谷歌获得我的页面速度结果时,我得到“对不起,我们只能为阿塞拜疆服务!” 错误