Hostnames and sub-sites¶
On which hostnames a site answers, and how a request finds its site.
The hostname of a main site¶
A main site answers on its Hostname, set on its
Hostnames section (/admin/sites/{site}/hostnames, see
Who sets the hostnames). Enter the bare hostname
in lower case, like www.hydrion.example: no scheme, port or path.
A hostname belongs to one site. The form refuses a hostname that another site uses as its hostname, an alias or a language domain, in any environment, and a hostname of the hub (The hub's hostnames). Changing the hostname moves every address of the site; add the old hostname as an alias to keep its links working.
Who sets the hostnames¶
The hostname, the hostname aliases and the language domains of a site need Manage site hostnames on that site, as a per-site role or a platform role, or Administer sites. Manage site settings does not cover them: a site manager without the permission sees the Hostnames section closed and no domain fields on the language detection page. The permission is restricted, so a delegate with Manage site members cannot hand it on.
Give it to people you trust with your domains. A hostname another site or the
hub answers on is refused, but any other host your server accepts can be
claimed: with wildcard DNS and a broad trusted_host_patterns entry, that is
every subdomain. A site that sets a hostname nobody routes to the server
answers nowhere until DNS points there.
The hub's hostnames¶
The hub has no hostname setting: it answers on every
host no site claims. List the hostnames it is reached on, of every
environment, under Hub hostnames on the General settings page
(/admin/sites/configuration/general). No site can take a listed hostname as
its hostname, alias or language domain, and no site answers on it even if its
settings say otherwise. The form also refuses the host it is submitted on
while that host is the hub's.
The update that adds the list writes the host it runs on, Drush's --uri or
the browser's, unless a site answers there. Add the other environments' hub
hostnames by hand. With the list empty, the status report shows the warning
Sites: hub hostnames.
Hostnames per environment¶
A hostname can differ per environment, like hydrion.ddev.site in the
local environment of a DDEV install and www.hydrion.example in the
default environment. Check Value per environment on the
Hostname and Hostname aliases rows of the site type, then set the
values on the Environments tab of the Hostnames section. An environment
without a hostname of its own uses the site's. An environment's aliases
replace the site's aliases; list every alias the environment answers to. The
whole installation runs in
one environment at a time, the one settings.php names: every site answers
on that environment's hostnames. A host a site has only in another
environment answers "Not Found" (404) in this one, like the host of a
disabled site, unless it is listed as a
hub hostname. See
Setting layers.
Hostname aliases¶
Hostname aliases on the Hostnames section are further hostnames of the
site, like hydrion.example (without www.) or a former domain. A request to an alias answers
with a permanent redirect (301) to the site's hostname, keeping the path and
the query. Aliases can differ per environment like the hostname.
Trusted hosts¶
List the hub's hostname in Drupal's trusted_host_patterns in
settings.php, plus the entry 'sites' => '.*'. Sites replaces that entry
with every
hostname, alias and language domain of every site, in every environment; see
Trust the hostnames for the snippet. A
site created later is trusted at once.
Without trusted_host_patterns, the status report (/admin/reports/status)
shows the error Sites: trusted host patterns.
A host the patterns admit that no site claims in any environment runs on the hub. Another environment's hostname of a site answers 404 (Hostnames per environment). Keep each environment's patterns to its own hostnames.
Sub-sites¶
Needs Sites path prefix
Part of Sites path prefix.
A sub-site belongs to a main site: it inherits the settings its type inherits from it and can be run by its people. Choose Sub-site under Structure when you create the site. Its Address is one of two:
- Under the main site's hostname, at a path prefix, like Hydrion UK at
www.hydrion.example/uk. The sub-site needs no DNS entry and has no hostname or aliases of its own. - A hostname of its own, like a campaign site at
www.hydrion-days.example. The hostname follows the rules of a main site's, aliases and language domains included, and the sub-site answers at its root with no prefix. It still belongs to its main site.
The address can change on the Hostnames section; nothing redirects the old addresses.
A path prefix:
- uses letters, digits,
-and_, in one or more segments likeukoruk/service, without a leading or trailing slash; - is unique on the platform;
- does not start with a reserved segment:
admin,user,node,taxonomy,sites,system,batch,cron,install,update,api,jsonapiorpreview.
A site stays a main site or a sub-site, and a sub-site stays with its main
site. The prefix can change on the Hostnames section; nothing redirects the
old addresses. A language path prefix comes first: www.hydrion.example/es/us.
How a request finds its site¶
Matching ignores case and port. There are no wildcards.
- Sub-site at a prefix: the host is a main site's hostname and the path starts with the prefix of one of its sub-sites. The longest matching prefix wins.
- Site on its hostname: the host is a site's hostname, one of its aliases or one of its language domains, as set for the current environment; a main site or a sub-site with a hostname of its own. An alias then redirects to the hostname.
- Hub: no site claims the host. The request runs on the hub.
A host whose only sites are disabled answers "Not Found", except to users with Access disabled sites or Administer sites. The prefix of a disabled sub-site is an ordinary path of its main site. A sub-site with a hostname of its own keeps its own status: disabling its main site takes the main site's host and the sub-sites at its prefixes down, not that sub-site. See Disable or delete a site.
Last updated 2026-11-22