robots.txt怎么写_robots.txt 不生效与站长平台配合
robots.txt 是搜索引擎抓取的规则文件,放在网站根目录,文件名必须小写。robots.txt 不生效时在 robots.txt 里写 User-agent 和 Disallow/Allow 规则,百度蜘蛛抓取前会先读 robots.txt,按规则决定是否抓取。注意 robots.txt 是建议性的,恶意蜘蛛不遵守,但百度、Google 等正规引擎严格遵守。
robots.txt 完整示例:User-agent: * 下 Disallow: /admin/、Disallow: /install/、Disallow: /?、Disallow: /*?*、Disallow: /temp/、Allow: /。Sitemap: http://域名/sitemap.xml。禁止后台、安装目录、动态参数 URL、临时目录,允许其余内容,末尾提交 sitemap 地址。
配置参考(robots.txt 标准示例): ``` User-agent: * Disallow: /admin/ Disallow: /install/ Disallow: /temp/ Disallow: /*?* Disallow: /*?page= Allow: /
User-agent: Baiduspider Disallow: /admin/ Disallow: /*?s=
Sitemap: https://域名/sitemap.xml ```
robots.txt 不要禁止 CSS、JS、图片文件。百度蜘蛛需要渲染页面,禁止 CSS/JS 会导致抓取异常、排名下降。Disallow 只针对动态页面和敏感目录,静态资源不要禁。如果蜘蛛抓取图片流量大,可以在站长平台调整抓取频率,而不是 robots 禁止图片。
robots.txt 与 301、404 的配合:页面已删除不要只靠 robots 禁止,要让页面返回 404 再提交死链;页面移动到新地址用 301,不要 robots 禁止旧地址(禁止后蜘蛛不抓取,301 无法传递权重)。robots.txt 管抓取范围,301 和 404 管状态码,三者配合才能完整控制收录。

更新时间:2026-09-02 14:27:10