Drupal Multi-site - Hosting Multiple Domains from a Common Codebase

Drupal multi-site has the advantage of using one codebase for multiple websites and therefore enabling an administrator to centrally maintain and upgrade the code while serving similar or different content to different website on different domains.

How to Implement Drupal Multi-site

  1. Point all your domains to the same root folder where Drupal is configured (You admin or hosting provider will point domains as needed)
  2. In the sites folder is a sub-folder called default which contains a file names settings.php [../sites/default/settings.php]
  3. Create a new folder within the ../sites/ folder bearing the exact name of the domain name you would like to handle (complete with/without the www depending on your preference) and save a copy of the original settings/php file int his folder [../sites/www.domain1.com/settings.php]
  4. Perform the above step for all the domain names that you would like to handle as well as their versions without www (e.g www.domain.com and domain.com should each have a seperate configuration folder)
  5. If you are planning to continue mirroring the domains to serve the same Drupal content, you donto need to do anything beyound this point. The identical settings will point all content requests from all the mirrored domains to be returned through the primary URL that you would like your site to be indexed and known by.
  6. If you would like to serve different content for each/some URLs, within each settings.php file for a domain that you would like to point elsewhere:
  7. Modify the database configuration and $base_url settings to reflect the location of the Drupal Database for each of the domains i.e

<?php

$db_url = 'mysql://databaseusername:dbpassword@dbserver/database_name';
$db_prefix = '';
$base_url = 'http://www.secondarydomain.com';

?>

Point to note:
If you are using clean URLs on an Apache server in the slightly different approach on installing multiple independent setups of Drupal in subfolders, remember to modify the .htaccess file in each setup folder to reflect the correct ReWritebase location.

Features and Benefits

Implementing multi-site hosting in Drupal enables you to handle and serve different content from parked/mirrored domains. A number of commercial hosting companies charge an extra fee to point an additional domain to a secondary folder. This Drupal feature enables you to have your host mirror all your domains to the root folder and from there you can configure Drupal to server different content to each domain or even mirror content and templates at your whim. You can even create conditions that dictate what content a domain should serve.

You can combine this setup with an IP-based hosting setup to host multiple domains each with a unique IP address from one Drupal codebase.

Another way to catering for requests with and without as the domain prefix is to enable the configuration setting within the .htaccess for Drupal 4.7+ You can also implement that setting for any other version of Drupal or other CMS or website hosted on Apache.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

Captcha
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
9 + 3 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.