Multiple Site Drupal - 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

$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.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Multisite drupal

Multisite drupal installations seem a bit unsecure. one thing that's always bugged me about the standard multisite installation is that images, videos, and other content uploaded for

http://domain.com

are accessible on

http://secondarydomain.com

as well... it also seems like keeping relying on

.htaccess

rules to protect folders full of config and installation files is inherently unsecure.

I did a writeup on a more secure multisite drupal solution that i've been using. it keeps individual site content separate, but still maintains all of the advantages of a standard multisite installation (single codebase to update, smaller disk space requirements, etc). it places the drupal codebase in a folder that isn't web accessible, and uses some symlink magic to include only what should be exposed to the rest of the interweb.

Valid XHTML 1.0 Strict
This site is accepts Oped ID authentication for login
This Website is Built Using Semantic Markup and Cascading Style Sheets (CSS)
Some usage rights are reserved, please contact us for approval before using it