From 9965e18ad97b1ffe2f6cdf8d71027bb72013fcf9 Mon Sep 17 00:00:00 2001 From: Eyre_S Date: Thu, 26 Jan 2023 17:12:57 +0800 Subject: [PATCH] add page robots.txt --- book.xml | 3 +++ enhanced/robots-policy.md | 48 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 enhanced/robots-policy.md diff --git a/book.xml b/book.xml index ece1705..fd3e17a 100644 --- a/book.xml +++ b/book.xml @@ -9,4 +9,7 @@ + + + diff --git a/enhanced/robots-policy.md b/enhanced/robots-policy.md new file mode 100644 index 0000000..61f5da3 --- /dev/null +++ b/enhanced/robots-policy.md @@ -0,0 +1,48 @@ +# robots.txt - 搜索引擎爬虫规则 + +[robots.txt]: https://en.wikipedia.org/wiki/Robots.txt + +ph-Bookshelf 提供了 `site.robots` 配置节点,可以允许站点管理员配置网站 [`/robots.txt`][robots.txt] 内容从而控制哪些网页可以被爬虫访问。 + +这个值只支持在站点配置(`bookshelf.xml`)中设置。因此,你无法在某个页面或是某个书籍的配置区域单独设置它们的访问控制。 + +默认取值为 `allow`。 + +支持设置值为 `allow` | `deny` | `custom` | `file`,或其它任何值。 + +{ #allow } +## allow + +当设置为 **`allow`** 时,将设置 robots.txt 为以下内容,这将允许任何爬虫访问网站的任何页面。 + +> 如果站点没有设置 `site.robots` 的值,那么这也是默认输出 + +```robots-txt +User-agent: * +Allow: / +``` + +{ #deny } +## deny + +当设置为 **`deny`** 时,将设置 robots.txt 为以下内容,这将允许任何爬虫访问网站的任何页面。 + +```robots-txt +User-agent: * +Allow: / +``` + +{ #file } +## custom / file + +当设置为 **`custom`** 或是 **`file`** 时,ph-Bookshelf 将会使用站点数据根目录中的 `robots.txt` 文件作为站点 robots.txt。 + +> 如果你的数据目录中没有这个文件,那么将会不产生任何内容。 +> 除非你的 PHP 的配置文件中 `display_error=On`:页面将输出 PHP 错误。 + +{ #others } +## 其它任何值 + +当填入的值不为以上任何值时,**ph-Bookshelf** 将会把填入的值作为 robots.txt 的内容输出。 + +因此,你可以使用 `` 直接在这里填入你想要设置的 robots.txt 内容。虽然我们仍然推荐使用 [`file`](#file) 方式而非这样的方式。