允许抓取外部Javascript文件

时间:2018-05-04 06:02:25

标签: seo robots.txt googlebot x-cart google-console-developer

我在谷歌控制台中遇到了我的网站问题

我在google console for my site

中出现以下错误

资源:

https://api.html5media.info/1.1.5/html5media.min.js 

Type : Script   

Status : Googlebot blocked by robots.txt

我的网站位于xcart,我的robots.txt包含

User-agent: Googlebot
Disallow: /*printable=Y*
Disallow: /*js=*
Disallow: /*print_cat=*
Disallow: /*mode=add_vote*

User-agent: *
Allow: *.js
Allow: *.css
Allow: *.jpg
Allow: *.gif
Allow: *.png
Disallow: /admin/
Disallow: /catalog/
Disallow: /customer/
Disallow: /files/
Disallow: /include/
....

我尝试过更改

User-Agent: Googlebot
Disallow: /*printable=Y*
Disallow: /*print_cat=*
Disallow: /*mode=add_vote*
Allow: .js

但上面的代码没有运气。 谁有解决方案?我如何使用我的robots.txt

允许谷歌机器人允许的第三方js

1 个答案:

答案 0 :(得分:2)

如果.js文件位于您无法控制的第三方网站上,则表示没有办法从您的网站取消阻止。给定的robots.txt文件仅控制对已加载robots.txt文件的域/子域上的文件进行爬网。要取消阻止此文件,您需要能够更改第三方域上的robots.txt文件。 (我假设你不能在这里这样做)

解决此问题的最简单方法是将js文件复制到您自己的服务器,然后链接到该服务器。