I have a multi-site setup that is working in Drupal 8 (8.6.13) - all of the sites share the code-base and database happily but I cannot seem to share data tables between the sites using the prefix array method - has this changed in Drupal 8 since older versions?

... I start off asking this since most of the data I am finding is for Drupal 7 or older and the solutions given seem valid but are not fully working when I try to implement them.

For example - I want a base (default) site to handle taxonomy, content types, and some admin functions like REST APIs. Each site can handle it's own content and theme (there are no users to worry about) and the sites/multi-site-1/settings.php is configured to handle this properly (I think).

in the base settings.php:

$databases['default']['default'] = array(
  'database' => 'base_database',
  'username' => 'db_user',
  'password' => 'db_password',
  'prefix' => array(
    'default'             => 'base_',
// ** content type and fields seem to share okay!
    'content_type_' => 'shared_',
    'content_field_' => 'shared_',

// ** the other tables with 'shared_' prefix that do not work shown below

and in the sites/multi-site-1/settings.php:

$databases['default']['default'] = array (
  'database' => 'base_database',
  'username' => 'db_user',
  'password' => 'db_password',
  'prefix' => array(
    'default'         => 'site_1_',

// ** can these even be shared?
    // 'config'              => 'shared_',
    // 'config_snapshot'     => 'shared_',

// ** users related things have errors when installing multi-site-1
    //'authmap' => 'shared_',
    //'profile_fields' => 'shared_',
    //'profile_values' => 'shared_',
    //'permission' => 'shared_',
    //'role' => 'shared_',
    //'sessions' => 'shared_',    //1. error - if sharing site won't even start install
    //'user' => 'shared_',        //3. error - "EntityStorageException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0' for key 'PRIMARY': "
    //'users' => 'shared_',
    //'users_roles' => 'shared_', //2. error - "The "user_role" entity type does not exist." 
    //'users_data' => 'shared_',  //2. error - "Table users_data already exists"
    //'users_field_data' => 'shared_',

// ** taxonomy related share seems okay but not working?
    //'taxonomy_index' => 'shared_',
    //'taxonomy_term_data' => 'shared_',
    //'taxonomy_term_field_data' => 'shared_',
    //'taxonomy_term__parent' => 'shared_', 
    //'vocabulary' => 'shared_',       // 1. install error - not present in D8 db?
    //'vocabulary_node_types' => 'shared_', 
    //'term_data' => 'shared_', // not present in D8?
    //'term_hierarchy' => 'shared_', // not present in D8?
    //'term_image' => 'shared_', // not present - n/a?
    //'term_lineage' => 'shared_', // not present - n/a?
    //'term_node' => 'shared_', // not present - n/a?
    //'term_relation' => 'shared_', // not present - n/a?
    //'term_synonym' => 'shared_', // not present - n/a?
  'host' => 'localhost',
  'port' => '3306',
  'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
  'driver' => 'mysql',
  'collation' => 'utf8mb4_unicode_ci',
  1. Should I abandon the multi-site config in this manner and rely on a contrib module like Domain Access? (I have tried to set this up but cannot seem to get it configured properly - or am not even sure what it is supposed to be doing for me).
  2. Is this still a good way to share data in the database in Drupal 8 or am I missing something?
  3. Am I adding in too much of the old v7 and v6 multi-site logic and Drupal 8 handles this differently?

any insights into how to do this better would be greatly appreciated!

some answers already read and referenced:

  • As from reading the linked resources it sounds shared database tables is considered a bad thing and probably will be removed from Drupal someday.
    – leymannx
    Commented Mar 27, 2019 at 17:26
  • I might need to rethink how we are setting this up then - @leymannx you also have a good answer about multi-site here could config splitting and sharing perhaps work better in this case?
    – rwcorbett
    Commented Mar 27, 2019 at 18:34
  • 1
    Yes, partially, together with the Features module. When you have for example a content type that will be the same on all instances, you export the content type on one instance into a feature (which basically is just a module), then enable (or import) that feature in another instance, and on both instances finally export config. So you can use Features to sync certain features across multiple sites, but still rely on config for each site. And important to note: Features can't sync content (nodes, terms, users).
    – leymannx
    Commented Mar 27, 2019 at 18:54
  • 1
    I think this is the module you meant to link => drupal.org/project/features. I will try like how you described
    – rwcorbett
    Commented Mar 27, 2019 at 19:00
  • Oops, yes, absolutely.
    – leymannx
    Commented Mar 27, 2019 at 19:06

1 Answer 1


posting my own answer with a brief explanation...

I have investigated the Config Split and Features modules and found that they are not providing what we need for this instance of Drupal running a set of sites.

The shared data and other interoperability that I need to be common between sites is not handled as I expect it to be... so my solution will be to have the Drupal instance direct users to the appropriate content on the site via redirects at the web server and then appropriate usage of paths and contextual filters.

If any other people find themselves here trying to answer similar questions with regards to Drupal 8 please take these into consideration:

    ## multi-site-1 ==> _workspace/base-site/web/sites/multi-site-1
       <VirtualHost *:80>
          DocumentRoot "/var/www/base-site.com/web"
          ServerName multi-site-1.com
          ServerAlias www.multi-site-1.com

          <Directory />
            Options FollowSymLinks
            AllowOverride None

          <Directory "/var/www/base-site.com/web">
              Options FollowSymLinks Multiviews Indexes
              AllowOverride All
              Order allow,deny
              Allow from all
              Require all granted
              MultiviewsMatch Any

          ErrorLog "/private/var/log/apache2/multi-site-1.com-error_log"
          CustomLog "/private/var/log/apache2/multi-site-1.com-access_log" common

and maybe something like this in .htaccess:

RewriteCond %{HTTP_HOST} ^(?:www\.)?multi-site-1\.com(.*)$ [NC] 
RewriteRule ^(.*)$ https://www.base-site.com/multi-site-1/$1 [L]

and thanks again to @leymannx for your help on this!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.