Skip to content

Multisite

  1. Snapshot your database so you can revert if needed:

    ddev snapshot
  2. Uncomment the following line in your .env file:

    .env
    # Multisite options
    ALLOW_MULTISITE=true
    # MULTISITE=true
    # DOMAIN_CURRENT_SITE=
    # SUBDOMAIN_INSTALL=false
    # PATH_CURRENT_SITE='/'
    # SITE_ID_CURRENT_SITE=1
    # BLOG_ID_CURRENT_SITE=1
  3. Install the following plugin using Composer

    ddev composer require roots/multisite-url-fixer
  4. Go to the WordPress admin.

  5. Disable all active plugins.

  6. Go to Tools > Network Setup.

  7. Pick the right settings and click on Install

  8. Update your .env file with the values shown on the WordPress admin screen:

    .env
    # Multisite options
    ALLOW_MULTISITE=true
    MULTISITE=true
    DOMAIN_CURRENT_SITE=your-project-name
    # SUBDOMAIN_INSTALL=false
    # PATH_CURRENT_SITE='/'
    # SITE_ID_CURRENT_SITE=1
    # BLOG_ID_CURRENT_SITE=1

    Replace your-project-name with the value shown on the WordPress admin screen

  9. Update your htaccess file with the value shown on the WordPress admin screen.

    web/.htaccess
    # BEGIN WordPress Multisite
    # Using subfolder network type: https://wordpress.org/documentation/article/htaccess/#multisite
    RewriteEngine On
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]
    # END WordPress Multisite
  10. Refresh the wp-admin tab and log back in.

  11. Re-enable your plugins.

Adding a new sub site throws an error when trying to visit the theme

Head over to web/app/mu-plugins/whoops-error-handler.php and comment out the following line

web/app/mu-plugins/whoops-error-handler.php
<?php
/**
* Plugin name: Whoops Error Handler
*/
// This checks necessary if you use the package as a dev dependency
if (!class_exists(Renakdup\WhoopsErrorHandler\ErrorHandler::class)) {
return;
}
$error_handler = new Renakdup\WhoopsErrorHandler\ErrorHandler('default-original');
$error_handler->init();
// $error_handler->init();

Refresh the page — it should work now. Once confirmed, re-enable the plugin:

web/app/mu-plugins/whoops-error-handler.php
<?php
/**
* Plugin name: Whoops Error Handler
*/
// This checks necessary if you use the package as a dev dependency
if (!class_exists(Renakdup\WhoopsErrorHandler\ErrorHandler::class)) {
return;
}
$error_handler = new Renakdup\WhoopsErrorHandler\ErrorHandler('default-original');
// $error_handler->init();
$error_handler->init();