首页 > 解决方案 > 在虚拟主机中禁用 robots.txt 中的子域索引

问题描述

我正在制作一个要在我的网站中使用的子域 ,例如:

example.com -测试.example.com

但我在单个机器人文件上使用,因为它只是一个虚拟子域

那么如何在我的机器人文件中启用 example.com 索引但同时禁用test .example.com

因为在搜索时我输入“联系我们”它会给出 example.com/contact-us 的结果并测试.example.com/contact-us

我只想显示 example.com 结果并且不索引test.example.com 以禁用其在搜索结果中的外观

所以我删除了谷歌搜索控制台中的链接,但我必须编辑 robots.txt

标签: google-searchrobots.txt

解决方案


robots.txt为您的子域创建一个单独的test.example.com,它test.example.com/robots.txt的内容如下所示。

User-agent: *
Disallow: /

确保你有一个单独的,正常的example.com/robots.txt


推荐阅读