【问题标题】:Redirect googlebot from my ajax page to static html page将 googlebot 从我的 ajax 页面重定向到静态 html 页面
【发布时间】:2013-05-27 14:45:27
【问题描述】:

我的主页调用是'www.xxxx/!#/hear-us'
我想将爬虫重定向到 html 版本调用hear-us.php 我用过

<?php 
    if (strpos($_SERVER['HTTP_USER_AGENT'],"Googlebot")) { 
        header('Location: http://xxxx/hear-us.php');
    } 
?>

当 url 提交给谷歌网站管理员时,它看不到重定向。

【问题讨论】:

    标签: php ajax redirect googlebot


    【解决方案1】:

    您可能希望在要发送的标头中添加实际的重定向代码,方法是在 Location 之前发送 Status 标头或使用:

    header("Location: /foo.php", TRUE, 301);
    

    注意,这是一个永久重定向,请根据需要更改代码。

    另外,一个好的做法是在发送标头后立即调用exit,否则任何输出都可能修改(或乱码)消息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-02-10
      • 2010-12-27
      • 2012-10-15
      • 2013-02-14
      • 2011-10-02
      • 1970-01-01
      • 2016-02-11
      • 2017-01-03
      相关资源
      最近更新 更多