robots.txt 语法
2025-03-27
56
参考资料
robots.txt 语法
robots.txt 文件用于指示网络爬虫(如搜索引擎的爬虫)如何访问网站的页面。其基本语法如下:
User-agent: 指定爬虫的名称。
*
表示所有爬虫。User-agent: *
Disallow: 禁止爬虫访问的路径。
Disallow: /private/
Allow: 允许爬虫访问的路径(通常与
Disallow
结合使用)。Allow: /public/
Sitemap: 指定网站地图的位置。
Sitemap: https://example.com/sitemap.xml
示例:
User-agent: * Disallow: /private/ Allow: /public/ Sitemap: https://example.com/sitemap.xml