Can a relative sitemap url be used in a robots.txt?

Easyrider picture Easyrider · Jan 7, 2013 · Viewed 143.2k times · Source

In robots.txt can I write the following relative URL for the sitemap file?

sitemap: /sitemap.ashx

Or do I have to use the complete (absolute) URL for the sitemap file, like:

sitemap: http://subdomain.domain.com/sitemap.ashx

Why I wonder:

  • I own a new blog service, www.domain.com, that allow users to blog on accountname.domain.com.
  • I use wildcards, so all subdomains (accounts) point to: "blog.domain.com".

In blog.domain.com I put the robots.txt to let search engines find the sitemap. But, due to the wildcards, all user account share the same robots.txt file.Thats why I can't use the second alternative. And for now I can't use url rewrite for txt files. (I guess that later versions of IIS can handle this?)

Answer

unor picture unor · Jan 8, 2013

According to the official documentation on sitemaps.org it needs to be a full URL:

You can specify the location of the Sitemap using a robots.txt file. To do this, simply add the following line including the full URL to the sitemap:

Sitemap: http://www.example.com/sitemap.xml