仅允许在index.html 上建立SE 索引

发布于 2024-08-19 15:40:59 字数 258 浏览 2 评论 0原文

阻止 * 并只允许主要搜索引擎仅索引该网站的索引页的最短方法是什么?

User-agent:  *
Disallow: /

User-agent: Googlebot
Disallow: /
Allow: index.html

User-agent: Slurp
Disallow: /
Allow: index.html

User-agent: msn
Disallow: /
Allow: index.html

这行得通吗?

What would be the shortest method to block * and only allow just Major Search Engines to index the index page of the site only?

User-agent:  *
Disallow: /

User-agent: Googlebot
Disallow: /
Allow: index.html

User-agent: Slurp
Disallow: /
Allow: index.html

User-agent: msn
Disallow: /
Allow: index.html

Would this work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

明月松间行 2024-08-26 15:40:59

是的,这将是最短的方法。这不一定是正确的。

并非所有机器人都支持 Allow 指令。当同时存在 User-agent: * 部分和 User-agent: Specific-bot 部分适用时,一些机器人对于如何解释 robots.txt 感到困惑。

为了确保它有效,您需要执行以下操作:

User-agent: Googlebot
Disallow: /file1
Disallow: /file2
Disallow: /file3
# etc. until you have blocked every path except index.html

User-agent: Slurp
Disallow: /file1
Disallow: /file2
Disallow: /file3
# etc. until you have blocked every path except index.html

User-agent: msn
Disallow: /file1
Disallow: /file2
Disallow: /file3
# etc. until you have blocked every path except index.html

User-agent:  *
Disallow: /

如果您不想完成所有这些工作,那么最好的办法是测试您感兴趣的每个引擎并查看他们是否接受您建议的 robots.txt 文件。如果没有,请尝试更长的版本。

Yes, that would be the shortest way to do it. It's not necessarily correct.

Not all bots support the Allow directive. And some bots are confused about how to interpret the robots.txt when there is both a User-agent: * section and a User-agent: Specific-bot section that apply.

To be sure it would work, you'd want to do something like this:

User-agent: Googlebot
Disallow: /file1
Disallow: /file2
Disallow: /file3
# etc. until you have blocked every path except index.html

User-agent: Slurp
Disallow: /file1
Disallow: /file2
Disallow: /file3
# etc. until you have blocked every path except index.html

User-agent: msn
Disallow: /file1
Disallow: /file2
Disallow: /file3
# etc. until you have blocked every path except index.html

User-agent:  *
Disallow: /

If you don't want to do all that work, then the best thing to do would be to test each of the engine's you're interested in and see if they'll accept the robots.txt file you proposed. If they don't, try the longer version.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文