跳转到主要内容

BookStack 配置 robots.txt

第一步:配置 .env

# 开启 robots 配置
ALLOW_ROBOTS=true
# 自定义主题,BookStack 通过自定义主题来覆盖默认 robots.txt
APP_THEME=custom

第二步:编写自定义 robots.txt

  1. 新建 themes/custom/misc/robots.blade.php 文件
  2. 贴入:
User-agent: *
@if($allowRobots)
Disallow: */export/
Disallow: /search
Disallow: /dist/
@else
Disallow: /
@endif

这里表示当允许 robots.txt 时,拒绝对 */export/、/search、/dist/ 目录的访问

参考文献

  • https://github.com/BookStackApp/BookStack/blob/development/dev/docs/visual-theme-system.md
  • https://github.com/BookStackApp/BookStack/blob/development/resources/views/misc/robots.blade.php