伪装背后的机制是什么?
What is mechanism behind cloaking?
根据this "Cloaking refers to the practice of presenting different content or URLs to human users and search engines" 同样的link给出了例子:
Serving a page of HTML text to search engines, while showing a page of images or Flash to users
问题:如果我没理解错的话,网络上一定有一种识别实体的机制,无论是搜索引擎还是浏览器(用户)server.What我们称之为这种机制吗?或者它只是重定向的 php 或 JavaScript 代码?网络服务器如何真正知道实体“X”搜索引擎和实体“Y”是网络浏览器?
用户代理是识别客户端的好方法。
这是根据浏览器的请求传递给服务器的用户代理字符串:
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"
来自Google:
Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
来自Bing:
Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)
要将它们与 PHP 一起使用,您可以这样做:
if (strpos($_SERVER['HTTP_USER_AGENT'],'bot') !== false) {
// This is probably a bot
}
如果你想更精确一点,你可能还想检查一个 link,像这样:
$userAgent = $_SERVER['HTTP_USER_AGENT'];
if (strpos($userAgent,'bot') !== false && strpos($userAgent,'http') !== false) {
// It is probably a bot
}
这个问题和答案展示了如何使用 Apache 根据用户代理传送不同的内容:Rewrite rule for user agent with mod_rewrite
根据this "Cloaking refers to the practice of presenting different content or URLs to human users and search engines" 同样的link给出了例子:
Serving a page of HTML text to search engines, while showing a page of images or Flash to users
问题:如果我没理解错的话,网络上一定有一种识别实体的机制,无论是搜索引擎还是浏览器(用户)server.What我们称之为这种机制吗?或者它只是重定向的 php 或 JavaScript 代码?网络服务器如何真正知道实体“X”搜索引擎和实体“Y”是网络浏览器?
用户代理是识别客户端的好方法。
这是根据浏览器的请求传递给服务器的用户代理字符串:
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"
来自Google:
Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
来自Bing:
Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)
要将它们与 PHP 一起使用,您可以这样做:
if (strpos($_SERVER['HTTP_USER_AGENT'],'bot') !== false) {
// This is probably a bot
}
如果你想更精确一点,你可能还想检查一个 link,像这样:
$userAgent = $_SERVER['HTTP_USER_AGENT'];
if (strpos($userAgent,'bot') !== false && strpos($userAgent,'http') !== false) {
// It is probably a bot
}
这个问题和答案展示了如何使用 Apache 根据用户代理传送不同的内容:Rewrite rule for user agent with mod_rewrite