我有一个网站(例如:www.examplesite.com),我在IIS中创建另一个站点作为一个单独的独立站点 . 第二个站点的URL将使其看起来像我的主站点:www.examplesite.com/anothersite . 这是通过在我的主站点下创建指向第二个站点的虚拟目录来完成的 .
我允许我的主站点(www.examplesite.com)在搜索引擎中编入索引,但我确实希望我的第二个虚拟目录站点被搜索引擎看到 . 我可以允许我的第二个网站拥有自己的robots.txt文件,并禁止该网站的所有网页吗?或者我是否需要修改我的主站点的robots.txt文件并告诉它不允许虚拟目录?
1 回答
您不能拥有自己的robots.txt目录 . 只有“主机”可以拥有自己的robots.txt:example.com,www.example.com,sub.example.com,sub.sub.example.com,...
因此,如果要为
www.example.com/anothersite
设置规则,则必须使用www.example.com/robots.txt
处的robots.txt .如果要阻止子站点的所有页面,只需添加:
这将阻止以"anothersite"开头的所有URL路径 . 例如 . 这些链接都被阻止了:
www.example.com/anothersite
www.example.com/anothersite.html
www.example.com/anothersitefoobar
www.example.com/anothersite/foobar
www.example.com/anothersite/foo/bar/
......
注意:如果您的robots.txt已包含
User-agent: *
,则必须在此块中添加Disallow
行,而不是添加新块(机器人会在找到与其匹配的块后立即停止读取robots.txt) .