Raised: $0
0% of monthly goal Help us cross the finish line!
Goal: $12,000
Raised: $0 Goal: $12,000
0% of monthly goal Help us cross the finish line!
Sponsor DDEV

DDEV Drupal Multisite Hostnames

This addon for Drupal projects creates a $sites entry for each multisite directory in the project. The entry is based on the name of the multisite directory and the DDEV project name.

For example, if your project name is my-ddev-project, and you have two multisite directories:

Then the $sites array will look like the following:

$sites = [
  'other-site.my-ddev-project.ddev.site' => 'other_site',
];

Why use this?

This addon was born of the desire to be able to run multiple copies of the same DDEV project on the same host simultaneously. In order to do this, you must have unique hostnames for each DDEV project/multisite directory combination.

If you do not need to accommodate this workflow, you may not need this addon, and can instead manually maintain additional_hostnames for your site directories. This workflow requires that you only have one instance of the same DDEV project running on your host at any given time.

Installation

ddev add-on get lpeabody/ddev-drupal-multisite-hostnames

Usage

Just install the addon and then run ddev start to apply the new hostname pattern, which by default is calculated using the pattern *.$DDEV_SITENAME.

  1. Install addon.
  2. ddev start
  3. ddev status and confirm that the wildcard site name URL was added.

Referring back to the example above, if you have the other_site directory then you should be able to now access that site via https://other-site.my-ddev-project.ddev.site.

Important

If you change the project name, and therefore the site name, you must run ddev multisite-start to regenerate the additional hostname file and apply it.

Note

Site directories named default and settings are ignored. The default directory is not necessary to set in most, if not all, circumstances in sites.php. The settings directory is conventionally used not as a site directory but as a location to store global settings files used by all sites.

Customizing the hostname pattern

You can manually edit the sites/sites.ddev_multisite.php file and the multisite-start command to customize the hostname pattern. When you update the addon you might have to reapply your changes.