【问题标题】:Google Ajax crawling is failingGoogle Ajax 抓取失败
【发布时间】:2015-11-22 17:03:33
【问题描述】:

我有一个 php ajax 网站,为我的用户提供页面

  http://www.example.com/ => this has all the individual page contents like listing
  http://www.example.com/#!page1-uid => has page1 contents, uid is the unique mongoDB identifier for that page
  http://www.example.com/#!page2-uid => has page2 contents, uid is the unique mongoDB identifier for that page

我希望谷歌抓取我的网站以索引所有大约 200 多个页面,但没有一个被索引

我几乎遵循并理解了 google ajax 抓取方法,但不确定我仍然缺少哪里/什么。

设置如下:

.htaccess

  RewriteCond %{HTTP_USER_AGENT} (googlebot|yahoo|bingbot|baiduspider) [NC]
  RewriteCond %{QUERY_STRING} _escaped_fragment_=(.*)$
  RewriteRule ^(.*)$ botIndex.php?QSA=%1 [QSA,L]

botIndex.php

$var1 = $_REQUEST['QSA'];
checks if QSA is set, if so, serves the individual page1/page2 
else gives out the default home page that has the listing of all the page links

当我使用 GWT(“fetch as google”)进行测试时,这是我观察到的模式

  a) www.example.com/ => it gets redirected to botIndex.php and returns me all the links (default view) just as expected
  b) www.example.com/#!page1-uid => redirects to the botIndex.php and returns me all the links but ideally it should return the actual page content instead of the home page contents (not sure GWT has the ability to ask for _escaped_fragment_ to mimic googlebot)
  c) www.example.com/?_escaped_fragement_ => GWT returns "Not found" error

通过在 botIndex.php 中添加少量回声,我怀疑上述请求均未显示“_escaped_fragment_”已被捕获 因此我的脚本 botIndex.php 没有获得 QUERY_STRING (QSA) 的值来服务 page1/page2 单个页面,而是始终 默认主页显示所有页面列表。

我直接测试了 botIndex.php 之类的 URL

  a) http://www.example.com/botIndex.php?_escaped_fragment_=QSA= (returns all the links )
  b) http://www.example.com/botIndex.php?_escaped_fragment_=QSA=page1-uid (returns the actual page details)

我还缺少什么?

我坚信 .htaccess 存在无法将 QSA 传递给我的脚本的问题。

请提出建议。

更新:我仍然卡住了。任何人都可以帮助我一些指针?

【问题讨论】:

    标签: ajax .htaccess mod-rewrite url-rewriting google-search-console


    【解决方案1】:

    显然,在重写期间保留 GET 参数有问题。尝试调试您的 .htaccess 指令。

    另一种选择是为您的 php 应用程序创建一个入口点,就像所有现代框架一样。并在您的 php 应用程序中实现所有逻辑(为机器人提供 html 内容)。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-09
    • 1970-01-01
    • 1970-01-01
    • 2011-01-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多