Community Documentation

Multiple domains using the same database

Last updated January 16, 2007. Created by karldied on December 15, 2002.
Edited by moshe weitzman, ax, kbahey, Steven. Log in to edit this page.

If you want to host multiple domains (or subdomains) on top of the same database (e.g. http://example.com/ and http://www.example.com/), simply use symbolic links to setup the required configuration files:

$ ln -s sites/example.com sites/www.example.com

$ ls -l sites
-rw-rw-r--    1 drupal   drupal      sites/example.com
lrwxrwxrrx    1 drupal   drupal      sites/www.example.com -> sites/example.com

If your installation isn't in the root folder then you need to specify the path to the Drupal installation. For example if the URL to your installation is http://www.example.com/drupal/ you would use sites/www.example.com.drupal with a settings.php file in it.

If you want cookies to be shared between two sites, you will need to set the value of PHP's session.cookie_domain correctly. In the case above, set it to ".example.com". You can do this through Drupal's .htaccess file.

About this page

Drupal version
Drupal 4.5.x or older

Installation guide

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.