指向本地站点地图的robotext文件

Gib*_*boK 5 html seo robots.txt

robots.txt文件中,是否可以使用相对路径而不是绝对路径来指出Sitemap?

Sitemap: http://www.example.com/sitemap.xml
Run Code Online (Sandbox Code Playgroud)

代替:

Sitemap: sitemap.xml
Run Code Online (Sandbox Code Playgroud)

Curiose note SO robots.txt

#
# this technically isn't valid, since for some godforsaken reason 
# sitemap paths must be ABSOLUTE and not relative. 
#
Sitemap: /sitemap.xml
Run Code Online (Sandbox Code Playgroud)

Joh*_*nde 3

官方站点地图文档在其示例中显示了完整的 URL,其中包含对 XML 站点地图位置的引用。

Sitemap: http://www.example.com/sitemap-host1.xml
Run Code Online (Sandbox Code Playgroud)

但是,它没有指定是否必须使用完整 URL 或绝对路径。StackOverflow robots.txt 暗示需要绝对路径,并且在使用相对路径时遇到问题。因此,如果您想确保搜索引擎找到您的站点地图,最好使用完整的 URL 或绝对路径。因为这很容易做到,所以我不认为有任何理由应该使用亲戚。