允许文件夹,但不允许特定的子文件夹

时间:2019-04-27 16:40:09

标签: robots.txt

对于robots.txt,我们如何允许使用文件夹,但不允许特定的子文件夹或页面?

例如,我的博客位于/blog内,但我想禁止/blog/wp-admin

下面的代码对我要实现的目标有用吗?

Disallow: /blog/wp-admin
Allow: /blog

1 个答案:

答案 0 :(得分:1)

使用

Disallow: /blog/wp-admin

这将禁止所有路径以/blog/wp-admin开头的URL:

  • https://example.com/blog/wp-admin
  • https://example.com/blog/wp-adminfoo
  • https://example.com/blog/wp-admin/
  • https://example.com/blog/wp-admin.php
  • https://example.com/blog/wp-admin/foo/bar

允许其他所有网址都被抓取,包括:

  • https://example.com/blog/wp-admi
  • https://example.com/blog/wp-adm
  • https://example.com/blog/wp-ad
  • https://example.com/blog/wp-a
  • https://example.com/blog/wp-
  • https://example.com/blog/wp
  • https://example.com/blog/w
  • https://example.com/blog/
  • https://example.com/blog
  • https://example.com/blo