微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

jQuery在/目录上的Webmaster Tools中导致404错误

Googlebot似乎在我的jQuery中爬行并创建以/ a结尾的链接,然后将其报告为404错误.
http://www.mySite.com/a

该网站在W3C验证绿色.

“/ a”来自jQuery本身.编辑:以下是jQuery v1.5和1.5.2中的一行代码(我看到的只有两个)

<a href='/a' style='color:red;float:left;opacity:.55;'>a</a>

现在,我在htaccess中将它重定向到它失控之前……

Redirect 301   /a   http://www.mysite.com

有谁知道Googlebot为什么/如何进入jQuery?

编辑:

我已经使用robots.txt文件阻止了jQuery文件,但我真的不希望Googlebot进入外部JavaScript文件.

编辑2:

以下是Google员工JohnMu在the thread I started at Google Groups关于此问题的回复.看起来我打算做301.

JohnMu

Google Employee

4:39 AM

Hi guys

Just a short note on this — yes,we
are picking up the “/a” link for many
sites from jQuery JavaScript. However,
that generally isn’t a problem,if we
see “/a” as being a 404,then that’s
fine for us. As with other 404-URLs,
we’ll list it as a crawl error in
Webmaster Tools,but again,that’s not
going to be a problem for crawling,
indexing,or ranking. If you want to
make sure that it doesn’t trigger a
crawl error in Webmaster Tools,then I
would recommend just 301 redirecting
that URL to your homepage (disallowing
the URL will also bring it up as a
crawl error – it will be listed as a
URL disallowed by robots.txt).

I would also recommend not explicitly
disallowing crawling of the jQuery
file. While we generally wouldn’t
index it on its own,we may need to
access it to generate good Instant
Previews for your site.

So to sum it up: If you’re seeing “/a”
in the crawl errors in Webmaster
Tools,you can just leave it like
that,it won’t cause any problems. If
you want to have it removed there,you
can do a 301 redirect to your
homepage.

Cheers

John

解决方法

看起来jQuery使用它作为测试模板来确定浏览器对功能支持.我不知道为什么谷歌机器人会看到这种情况.我不知道网络抓取工具通常运行任何Javascript.这意味着它们实际上是作为一个网络浏览器运行(我想知道哪一个?).似乎不太可能.

(编辑 – 请参阅:how do web crawlers handle javascript – 表示谷歌可能会尝试从脚本中提取一些东西.很惊讶它不会被编程识别jQuery的一部分,你是否使用非标准名称?)

或者,您的jQuery包含的标头是否有可能不正确?也许它是由HTML mime类型提供的,大多数浏览器可能不关心,因为它们的类型也是由脚本包括设置,但也许机器人会决定解析.

无论如何,不​​是设置重定向,为什么不使用robots.txt?添加此行:

disallow: /a

你也可以尝试修复jQuery.稍微混淆链接可能会成功,例如更改违规行:

div.innerHTML = "   <link/><table></table><"+"a hr"+"ef='/a'"
  +" style='color:red;float:left;opacity:.55;'>a</a><input type='checkBox'/>";

如果谷歌足够聪明,实际上解析字符串连接,这会让我感到震惊,你可以再进一步,将一些像“href”这样的东西分配给一个变量然后与之连接.我无法相信他们的js扫描仪会走得那么远,这基本上就像试图运行它一样.

原文地址:https://www.jb51.cc/jquery/180622.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐