在 robots.txt
文件中,是否可以使用相对路径而不是绝对路径来指出站点地图?
Sitemap: http://www.example.com/sitemap.xml
改为:
Sitemap: sitemap.xml
好奇笔记 SO robots.txt
#
# this technically isn't valid, since for some godforsaken reason
# sitemap paths must be ABSOLUTE and not relative.
#
Sitemap: /sitemap.xml
最佳答案
The official sitemap documentation在包含对 XML 站点地图位置的引用的示例中显示了完整的 URL。
Sitemap: http://www.example.com/sitemap-host1.xml
但是,它没有指定是否必须使用完整的 URL 或绝对路径。 StackOverflow robots.txt 暗示需要绝对路径,并且他们在使用相对路径时遇到了问题。因此,如果您想确保搜索引擎找到您的站点地图,最好使用完整的 URL 或绝对路径。因为这很容易做到,所以我看不出有任何理由应该使用亲戚。
关于html - 指向本地站点地图的 robotext 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7245590/