doupo2241 2017-04-24 01:23
浏览 41
已采纳

隐藏真实背后的机制是什么?

According to this "Cloaking refers to the practice of presenting different content or URLs to human users and search engines" The same link gives example as:

Serving a page of HTML text to search engines, while showing a page of images or Flash to users

Question: If I had correctly interpreted, there must be a mechanism for identification of the entity whether it is search engine or browser(user) at the web server.What do we call such mechanism? Or is it just a php or JavaScript code that redirects? How does a web-server actually know that entity'X' search engine and entity'Y' is web browser?

  • 写回答

1条回答 默认 最新

  • doumianfeng5065 2017-04-24 01:33
    关注

    The user agent is a good way to identify the client.

    This is the user agent string passed to the server on a request from a browser:

    "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"

    From Google:

    Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)

    From Bing:

    Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)

    To use them with PHP, you may do something like this:

    if (strpos($_SERVER['HTTP_USER_AGENT'],'bot') !== false) {
        // This is probably a bot
    }
    

    If you want to be a little more precise, you might want to also check for a link, like so:

    $userAgent = $_SERVER['HTTP_USER_AGENT'];
    if (strpos($userAgent,'bot') !== false && strpos($userAgent,'http') !== false) {
        // It is probably a bot
    }
    

    This question and answers show how to use Apache to deliver different content based on user agent: Rewrite rule for user agent with mod_rewrite

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 连续两帧图像高速减法
  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写