【问题标题】:robots.txt file is probably invalid [closed]robots.txt 文件可能无效[关闭]
【发布时间】:2012-05-07 14:26:40
【问题描述】:

这是我的robots.txt。我只想允许基本 url domain.com 用于索引并禁止所有子 url,如 domain.com/foodomain.com/bar.html

User-agent: *
Disallow: /*/

因为我不确定这是否是有效的语法,所以我使用 Google 网站管理员工具对其进行了测试。它向我显示了这条消息。

robots.txt file is probably invalid.

我的文件有效吗?有没有更好的方法只允许基本 url 进行索引?

更新:Google 在 4 小时前下载了我的 robots.txt。我认为这就是为什么它不起作用。我会等待一段时间,如果问题仍然存在,我会再次更新我的问题。

【问题讨论】:

标签: indexing web-crawler robots.txt


【解决方案1】:

这是一个验证器的链接。它可能会帮助您解决文件中的任何错误。

Robots.txt Checker

我检查了另一个验证器 robots.txt Checker,这就是我在第二行得到的结果:

此处不允许使用通配符(如“*”) 下面的行 必须是允许、禁止、注释或空行语句

这可能是您正在寻找的:

User-Agent: *
Allow: /index.html
Disallow: /

这假设您的主页是 index.html。

如果 index.php 是您的主页,您应该可以将 index.html 换成 index.php。

User-Agent: *
Allow: /index.php
Disallow: /

在我通过 index.php 运行的动态网站上,转到 mydomain.com/index.php 仍然会将我带到主页,所以上述应该可以工作。

【讨论】:

  • index.html 不是我的主页,因为所有请求都指向 index.php,它管理内容和布局。所以我只需要允许基域。
  • 访问 yourdomain.com/index.php 会带你到主页吗?
  • 是的,因为 .htaccess 重定向到 yourdomain.com
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-09-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多