Is it possible to use the same Drupal code base for different Drupal sites, just by changing settings.php and the database settings, and accessing it through a subdomain?

1 Answer 1


coleopterist is right.

Let's say you want mydomain.com and sub.mydomain.com to share the same codebase, you will have to put two folders in sites/ :

  • sites/mydomain.com/
  • sites/sub.mydomain.com/

If you want modules and themes to be available to all domains defined in sites/, all you have to do is to put them in all/ :

  • sites/all/modules/
  • sites/all/themes/

Then, in sites/{domain}/settings.php you can redefine the databases strings like so :

$databases = array (
  'default' => 
  array (
    'default' => 
    array (
      'database' => 'database_name',
      'username' => 'user_name',
      'password' => 'p4ssw0rd',
      'host' => '',
      'driver' => 'mysql',
      'prefix' => 'drupal_',

Note that you should launch the DrupalRoot/install.php script for each different domain to create its database tables.

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.