Domains, redirects and crawler files

Two files and one table decide how a site is found and how crawlers read it: the domain rows say which host belongs to which site, the redirect table says where an old address goes now, and sitemap.xml with robots.txt tell a crawler what to keep. The site's own URLs are canonicalised before any of that runs.

Which site answers a host

A request arrives with a host name. Which site answers it is decided in one fixed order, and the order is the contract:

Step What decides
1 www. is dropped before any comparison
2 A host under the deployment's own primary domain is the hosted form: the subdomain picks the site by its alias; a site with no alias is 301'd to the deployment's primary alias, and a www. request on this form is 301'd to the alias host
3 Otherwise a domain row decides: the name must match the host and the row must be public. No row is 404 — the platform never guesses a site for an unknown host
4 The domain's prefix setting canonicalises apex and www — add www, drop it, or leave the host alone

A site that is marked not live answers 503 rather than serving its content, on either form.

Domain rows are managed through the admin API:

Call Answers
GET /api/domains?siteId= The site's domains, a page at a time
GET /api/domains/{id} One domain row
POST /api/domains/save Creates or updates a domain. DomainId, SiteId and Name are required — send the identifier you want the row to have; one that names no existing domain creates the row. A name already claimed by another domain answers 400
DELETE /api/domains/{id} Removes the row — the host stops resolving
curl -X POST "$ADMIN_API/api/domains/save" \
  -H 'content-type: application/json' \
  -b cookies.txt \
  -d '{
    "DomainId": "<uuid>",
    "SiteId": "<site-id>",
    "Name": "shop.example.com",
    "Public": true,
    "PrefixAction": 1
  }'

A name is stored lower-cased, and the uniqueness check runs across every site — one host cannot belong to two sites. PrefixAction is 1 to add www, 2 to drop it, and 0 (the default) to leave the host as it arrives; the redirect it causes is 301 for a read and 307 for any other method, because a browser re-issues a 301'd POST as a bodyless GET.

A row also carries three more values:

Key Effect
ThemeId Pins a theme for this host, whatever the site's active theme is
SettingsData Settings stored for that host. The platform itself does not read them back
RobotsTxt The robots.txt body for this host (below)

The canonical form of a page address

Before a page is rendered, and before the redirect table is consulted, a read is checked against its canonical form: lower case, no trailing slash, no doubled slash. A request that differs is answered with 301 to the canonical address, and the query string is preserved.

That check only ever touches a page. Asset and machine paths — /themes/, /assets/, /images/, /css/, /js/, /api/, the exact paths /favicon.ico, /robots.txt and /sitemap.xml, and anything whose last segment carries a file extension — are left exactly as they arrive: lower-casing Logo.CSS or redirecting an asset would break the page that links it.

Redirects

The redirect table belongs to a site, and every row is tried in Seq order — the first match wins:

Key Meaning
Title A name for the row, for whoever reads the table
TargetUrl The source — what a request is matched against. The name is historical
SourceType 1 matches the path with its query, 2 matches the host, anything else matches the whole absolute URL
DestinationUrl Where a match goes
Regex Treat TargetUrl as a regular expression instead of a literal string
IgnoreCase true by default, for a literal comparison and for the regex
Permanent For a GET or HEAD, 301 when true (the default) and 302 when not; any other method is answered with 307
Action 1 is a redirect. Any other value does nothing on this path
Seq The order the rows are tried in

A regex row substitutes what it matched into the destination, so one row can cover a family of old addresses:

curl -X POST "$ADMIN_API/api/redirections/save" \
  -H 'content-type: application/json' \
  -b cookies.txt \
  -d '{
    "SiteId": "<site-id>",
    "Title": "Old product pages",
    "TargetUrl": "^/catalog/([a-z0-9-]+)/?$",
    "DestinationUrl": "/products/$1",
    "SourceType": 1,
    "Regex": true,
    "Action": 1,
    "Permanent": true,
    "Seq": 10
  }'

When several destinations compete for one position, POST /api/redirections/move puts a row at a Seq and shifts the rows it passed, so the table stays a list of distinct positions:

curl -X POST "$ADMIN_API/api/redirections/move" \
  -H 'content-type: application/json' \
  -b cookies.txt \
  -d '{ "redirectionId": "<uuid>", "siteId": "<site-id>", "sourceSeq": 10, "targetSeq": 1 }'

Three rules a reader should know before writing rows:

Updates, listing and deletion are POST /api/redirections/save, GET /api/redirections?siteId=, GET /api/redirections/{id} and DELETE /api/redirections/{id}.

A front end that renders content as a consumer of the public API has no database of its own, and its redirects are part of the behaviour it has to reproduce. GET /redirections on the content API answers the same rows as JSON, in the same Seq order, with sourceUrl naming the value to match and destinationUrl the target.

robots.txt

One body per host, resolved in this order:

  1. the RobotsTxt of the domain row that answered the host;
  2. otherwise the site's own RobotsTxt (POST /api/sites/save);
  3. otherwise a permissive default — every agent allowed, nothing disallowed.

Both RobotsTxt values are set as whole file bodies, so a site can keep a sitemap line next to its own rules:

curl -X POST "$ADMIN_API/api/domains/save" \
  -H 'content-type: application/json' \
  -b cookies.txt \
  -d '{
    "DomainId": "<uuid>",
    "SiteId": "<site-id>",
    "Name": "shop.example.com",
    "RobotsTxt": "User-agent: *\nDisallow: /cart/\nSitemap: https://shop.example.com/sitemap.xml"
  }'

The answer is served as text/plain.

sitemap.xml

/sitemap.xml is an index: it names the chunk files a crawler then reads. Each chunk is sitemap-<source>-<page>.xml, holds up to 50 000 URLs, and empty sources are left out of the index entirely — an index never advertises a file that would be empty.

<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <sitemap><loc>https://shop.example.com/sitemap-pages-1.xml</loc></sitemap>
  <sitemap><loc>https://shop.example.com/sitemap-blog-3F2A1C10-posts-1.xml</loc></sitemap>
</sitemapindex>

A source key derived from a container carries that container's identifier in upper case, so sitemap-blog-3F2A1C10-posts-2.xml is the second chunk of that one blog's posts.

What a sitemap lists, and what controls it:

Listed Controlled by
Pages, static pages, blog posts, products The row's includeInSitemap (true by default) and published — both must be true
A blog, store or catalog's own index page Its includeInSitemap
Categories, tags and vendors Nothing: every one is listed, because these rows carry no opt-out and no sitemap hints
lastmod, changefreq, priority The row's sitemap hints, per entry; a taxonomy entry carries none

Tables and reviews never appear: neither has a URL of its own.

Every <loc> is absolute, built from the site's own origin — the deployment's configured site URL when there is one, otherwise https:// plus the site's primary domain. It is never the host of the request that asked for the sitemap: that answer is cached per site, and a request-derived origin would be poisoned by whoever asked first.

A theme that serves its own pages omits a taxonomy segment whose listing layout does not exist — a category listing with no layout answers 404, so its URLs do not belong in a sitemap. Headless, the same sitemap lists them: whether a consumer can render a category is the consumer's business.

Related