如何使用robots.txt只允许爬虫访问index.php?
如果我只想允许爬虫访问index.php,这行得通吗?
User-agent: *
Disallow: /
Allow: /index.php
If i want to only allow crawlers to access index.php, will this work?
User-agent: *
Disallow: /
Allow: /index.php
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
是的,它会起作用。以下是 Google 网站站长工具的测试结果。
但是,请记住,使用此配置时,除非使用完全限定路径访问该页面,否则不会对您的网站主页进行爬网。
换句话说,
http://www.example.org/
是被禁止的,而http://www.example.org/index.php
是允许的。如果您希望主页可供访问,这里有一个更好的文件版本。
Yes, it will work. Here's the test result from the Google Webmaster Tool.
However, remember that with this configuration your site homepage won't be crawled unless the page is accessed with the full qualified path.
In other words,
http://www.example.org/
is forbidden whilehttp://www.example.org/index.php
is allowed.If you want your homepage to be accessible, here's a better version of your file.
尝试交换禁止/允许的顺序:
请参阅维基百科中的此信息:
http://en.wikipedia.org/wiki/Robots.txt< /a>
尽管如此,我还是不希望它能太一致地工作
Try swapping the order of Disallow / Allow:
See this info from wikipedia:
http://en.wikipedia.org/wiki/Robots.txt
Still I wouldn't expect it to work too consistently
您可以使用 Google Robots 工具进行结帐。我永远不会在 robots 文件中放入任何秘密目录,因为我猜测像下面这样的行对于某些蜘蛛来说就像蜂蜜一样。
You can use the Google Robots tool to checkout. I would never put any secret directories in the robots file as I would guess that a line like below would be as honey for certain spiders.