文档说明:
robots.txt是放置在网站根目录下的文本文件,用于指导搜索引擎爬虫的抓取行为。
基本语法:
- User-agent:指定适用的爬虫(如 User-agent: * 表示所有爬虫)。
- Disallow/Allow:定义禁止或允许的路径。
示例:
User-agent: * #所有爬虫
Disallow: /private/ # 禁止抓取 /private/ 目录
Allow: /public/ # 允许抓取 /public/ 目录
说明:使用#号添加解释说明
使用方法:
1.在网站根目录新建robots.txt文件(注意大小写规范)
2.配置以下内容
User-agent: *
Disallow: /admin/
Disallow:/install/