In short. A host-matching Fastly VCL snippet maps /sitemap.xml to the matching domain sitemap stored under pub/media.
Definition: Adobe Commerce on cloud infrastructure can serve a different sitemap file for each domain by storing domain-specific files under
pub/mediaand using a custom Fastly VCL snippet. The snippet matches the request host and rewrites/sitemap.xmlto the matching media file.
Key facts
- Adobe's cloud sitemap and robots documentation says cloud projects can write to specific directories including
pub/media, and the Admin sitemap path is/media/. - The domain example uses files named
pub/media/domain_robots.txtandpub/media/domain_sitemap.xml, withdomainrepresenting the host label. - The combined snippet matches
/sitemap.xml, testsreq.http.hostagainst(domain).com$, and builds the media path withre.group.1. - Adobe's custom VCL snippets documentation says snippets can be managed from the Adobe Commerce Admin or through the Fastly API.
What must be created in Adobe Commerce cloud?
Adobe's cloud documentation, last updated 8 October 2026, says a sitemap write at the project root produces this error:
Please make sure that "/" is writable by the web-server.
The same page lists var, pub/media, pub/static, and app/etc as specific writable directories. Its Admin instructions use sitemap.xml as the filename and /media/ as the path. For the domain-specific setup, the page says to create these files, where domain.com is the example host:
pub/media/domain_robots.txt
pub/media/domain_sitemap.xml
The generated sitemap content therefore lives in the media directory, while the public request can remain /sitemap.xml.
How does the host-specific Fastly rule work?
Adobe's documented Fastly VCL example uses a custom snippet with the type and content key-value pairs. Its combined rule is:
{
"name": "domain_sitemaprobots",
"dynamic": "0",
"type": "recv",
"priority": "90",
"content": "if ( req.url.path == \"/robots.txt\" ) { if ( req.http.host ~ \"(domain).com$\" ) { set req.url = \"/media/\" re.group.1 \"_robots.txt\"; }} else if ( req.url.path == \"/sitemap.xml\" ) { if ( req.http.host ~ \"(domain).com$\" ) { set req.url = \"/media/\" re.group.1 \"_sitemap.xml\"; }}"
}
For a request whose host ends in domain.com, the capture group supplies domain. The sitemap branch then sets the request path to /media/domain_sitemap.xml, which corresponds to the file at pub/media/domain_sitemap.xml. The same snippet applies the parallel rule for /robots.txt and pub/media/domain_robots.txt. Adobe describes the robots request explicitly as http://domain.com/robots.txt presenting the media file.
Where is the snippet managed?
Adobe's custom VCL documentation defines a custom VCL snippet as VCL logic added to the active VCL version uploaded to the Adobe Commerce site. It says regular snippets can be created, modified, and deployed from the Admin or the Fastly API, while dynamic snippets are created with the Fastly API.
The cloud sitemap page says custom snippets can be uploaded from the Admin UI or with the Fastly API. The custom VCL page adds that Fastly services must be configured for the environment before custom snippets can be added to a Staging or Production environment. The sitemap page also says the Admin sitemap configuration for this routing pattern must use pub/media/ rather than /.
Related terms
- Why can PWA Studio hide Adobe Commerce's configured robots.txt?
- Does a physical robots.txt file override Adobe Commerce's generated rules?
FAQ
Does the public sitemap URL need to include the domain filename?
No. The documented snippet matches /sitemap.xml and rewrites the request internally to the domain-specific file under /media/. The public path stays /sitemap.xml for the host matched by the rule.
Can one Fastly snippet handle robots.txt and sitemap.xml?
Yes. Adobe provides one JSON snippet with separate branches for /robots.txt and /sitemap.xml, using the host capture to select the matching media file.
Which Admin path is used for this domain routing pattern?
Adobe's standard sitemap steps show /media/ in the New Site Map form. The domain-specific instructions say to use pub/media/ in the sitemap Admin configuration for the routing example.
Sources
- Adobe, "Add site map and search engine robots", 8 October 2026
- Adobe, "Get started with custom VCL snippets", 20 August 2025
Check how a page reads to answer engines. Open the GEO score analyzer