Last updated May 2, 2013. Created on March 12, 2006.
Edited by EnjoyLife, arianek, JohnNoc, alexanderpas. Log in to edit this page.

Drupal's multi-site hosting capability is built in with any installation. This is great news for users who run numerous web sites from a single hosting account. A single Drupal installation can be used to run multiple domains, which makes it much easier to manage and maintain the code base. Even if you are dealing with only one domain, the multi-site capability may be valuable by providing the ability to run a separate domain or sub-domain for a development version.

This page describes the set-up of the /sites directory for multi-sites.

With version 5.x, the intended location for all non-core elements of a Drupal installation is in a separate /sites directory inside the Drupal installation.

Directory Contents

(used by all sites)

(used when there is no /sites/ directory)
/drupal/sites/    /files
/drupal/sites/    /files

The intended best practice configuration is to create a /sites/ directory for each domain. It should contain a site-specific settings.php file and /files directory. Configure Drupal site settings to specify 'File System Directory' of 'sites/' instead of the default 'files'. It's possible to do this with an existing web site, but moving file uploads around can cause a lot of confusion if there are already URLs pointing to the old locations.

Domain specific modules and themes should also be placed in /sites/ and /sites/ respectively.

Contributed modules and additional themes which are for use by all domains in a multi-site installation should be placed in /sites/all/modules and /sites/all/themes. Note that there shouldn't be a /sites/all/files or /sites/all/settings.php.

The /sites/default directory should contain /files and settings.php, for use if the /sites/ directory doesn't exist for a domain.

In addition to multiple sites, such as and, sub domains are also easily set up. Adding and, the directory structure for these four sites would be:


Note that Drupal reconizes as a sub-domain of
If you wish to point both of them to the same site, use /drupal/sites/ as your directory, and uncomment the corresponding option in your .htaccess

Once you've done this, the file structure of your site will be cleanly organized:

  • The main Drupal directory will contain only the standard 'core' files.
  • Themes and modules that are shared among all sites are properly placed in /sites/all
  • Site-specific themes, modules, and files are compartmentalized and properly placed in /sites/, /sites/, /sites/ and /sites/ .
  • /sites/default/settings.php and /sites/default/files will be used if /sites/ directory does not exist.
  • Backing up the /sites directory and your Drupal database will give you everything you need to restore the site in the event of a crash, or to move to a new server.
  • Adding a domain is easy: just copy the /sites/default directory to /sites/

To help keep files organized you may choose to use shortcuts to point relevant files and directories that are stored elsewhere in your Drupal installation. These short-cuts (like a desktop "alias") are referred to as "symbolic links" on a Web server. Symbolic links can be used for several purposes:

  • Even if using default settings, a good option is to use links from /sites/ directory to point to the /sites/default directory. That way, if the settings and /files are ever changed from the default and actually placed in /sites/, their location does not 'move' and no links are broken.
  • Links could also be used to point the /sites/default directory to your primary site.
  • A /files directory could easily be shared across two domains without being shared across the remaining domains.
  • A non-domain-name path for /files can be setup. If it is possible that the domain name might change (say, from a development name), then you can set up a link from /drupal/sites/moniker to /drupal/sites/, where 'moniker' is a short version of the site name that will remain constant even if / changes.

If you are working from the command line on a Linux, Unix or OSX server you can create a symbolic link using the following command:
$ ln -s /path/to/actual/file/or/directory name_of_shortcut

Although the /sites/default directory could contain a /modules and /themes directory, these elements should usually be placed in /sites/all or /sites/ Similarly, although contributed modules could be placed in /drupal/modules as was the practice in version 4.7, this is not recommended.

Multi-site directory setup for sub-domains, including non-standard ports, is described in the installation instructions found in INSTALL.txt.

See multidomain for a contributed module that allows spanning one site across multiple domains, so that specific content types appear on specific domains or sub-domains.

Version 4.6 and 4.7: Best practice for multi-site set-up under version 4.6 and 4.7 is similar to 5.x. The primary difference is that there is no /sites/all directory. Instead, /modules and /themes that are available for all domains are kept in /drupal/modules and /drupal/themes.

Files Directory
The following user-submitted code may be useful in redirecting URLs for the /files directory to the /sites/ directory. The following code is added to the [drupal_root]/files/.htaccess file:

<IfModule mod_rewrite.c>
  RewriteEngine on

  # Note: this will redirect to the /sites subfolder which is identical to
  # the domain accessed by the browser.  If you use partial domain names as
  # the /sites subfolder (e.g. /sites/ vs /sites/
  # you will need to modify the Drupal root .htaccess to remove the leading www
  # or modify the following to use the protion of %{HTTP_HOST} that mirrors
  # your /sites subfolders

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} ^(.*)\/files\/
  RewriteCond %1/sites/%{HTTP_HOST}/files -d
  # To redirect the URI to the actual location of the file /sites/<domain>/files/<filesname>
  # change the [L] to [L,R]
  RewriteRule ^(.*)$ /sites/%{HTTP_HOST}/files/$1 [L]

  # If the domain does not have a dedicated /sites/<domain>/files folder allow the
  # default folder to catch it.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  # To redirect the URI to the actual location of the file /sites/default/files/<filename>
  # change the [L] to [L,R]
  RewriteRule ^(.*)$ /sites/default/files/$1 [L]


If the .htaccess method doesn't work, try this user-contributed code for use in settings.php, instead of .htaccess.

In settings.php, put this code:

['file_directory_temp'] = 'sites/' .substr(strrchr(dirname(__FILE__), '/'), 1) .'tmp';
$conf['file_directory_path'] = 'sites/' .substr(strrchr(dirname(__FILE__), '/'), 1) .'/files';

Looking for support? Visit the forums, or join #drupal-support in IRC.


rebafc’s picture

I'm using Drupal 6. To implement multisite I parked a secondary domain over the primary domain and so don't need or use symlinks or aliases (which are always an issue on shared hosting). It's all run out of a single database with a prefix for each set of tables. The basic setup was easy. Congratulations Drupal developers.

The issue I faced was the ability to provide separate upload directories for each domain.

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /sites/%{HTTP_HOST}/files/$1 [L]

This Mod Rewrite code sounded about right but I struggled to get it working. I eventually discovered if I accessed the domain without including www. in the URL the Mod Rewrite worked as predicted. With the benefit of hindsight this makes sense as the domain name in the /sites directory doesn't include the www. prefix. So now I have changed the .htaccess in the root directory to rewrite the URL and eliminate the www. prefix. [There was sample code in the supplied .htaccess, so again this was pretty easy.]

The limitation I see with this solution is the need to add a new rewrite condition and rule for each domain hosted with a requirement for an upload directory.

I hope my experience can help someone else struggling with this.

BarisW’s picture

Thankx rebafc for your code and thoughts!

I used your code and it sort of works.

All requests to http://dev-site.intranet.lan/files/filename.jpg resolve to http://dev-site.intranet.lan/sites/dev-site.intranet.lan/files/filename.jpg

So far this is great!

But how can I get Drupal to call the files using the shorter URL?
So a sourceview of my page doesn't give away the sites/sitename/files directories?

Baris Wanschers (@BarisW)
Drupal specialist

Matto’s picture

Excellent resource page, just wondering if there should be a /drupal/sites/default/tmp folder added to the list after the fourth item (/drupal/sites/default/settings.php) in the example ideal directory structure list.

Apologies if this is a dumb suggestion and/or I've posted this suggestion in the wrong place.

- Matto Rochford
Drupal Content Consultant, Sydney

omc’s picture

I just realized a problem on my server, when I try to access the folder it gives me this error message:

ou are not authorized to view this page
You do not have permission to view this directory or page due to the access control list (ACL) that is configured for this resource on the Web server.

Please try the following:

* Contact the Web site administrator if you believe you should be able to view this directory or page.
* Click the Refresh button to try again with different credentials.

HTTP Error 401.3 - Unauthorized: Access is denied due to an ACL set on the requested resource.
Internet Information Services (IIS)

Technical Information (for support personnel)

* Go to Microsoft Product Support Services and perform a title search for the words HTTP and 401.
* Open IIS Help, which is accessible in IIS Manager (inetmgr), and search for topics titled About Security, Access Control, and About Custom Error Messages.

IIS is trying to serve the .com as the filetype .com which triggers a username/password prompt and then the above error message.

Any ideas on how to make it so drupal can still use the directories w/o ".com" on the end or a way to fix IIS?

Its not folder permission issue, as I can rename the folder to anything not .com and it works (.org, .net, etc) but then drupal breaks for the website...

donquixote’s picture

If you are working from the command line on a Linux, Unix or OSX server you can create a symbolic link using the following command:
$ ln -s /path/to/actual/file/or/directory name_of_shortcut

Fine. And what about Windows?
I tried with the usual windows shortcuts, but this didn't do the trick...

The use case:
- on the web server I have a multi-site setup with [drupal-root]/sites/, [drupal-root]/sites/, etc, for different subdomains.
- on my localhost I want to mirror this drupal installation, but I would like to use different domains, such as "site1.localhost" and "site2.localhost".
- later I want to deploy a production version with dedicated domains, such as,, I do not want to rename the subdirectories in [drupal-root]/sites.

donquixote’s picture

I found a solution:

On Windows XP you can use the Windows junction utility, see

Somewhere I read that Windows Vista or Windows 7 do support symlinks, so I guess you don't need the junction utility there.

nomadcanuck’s picture

The Junction utility is an excellent utility and I have used it to reduce much duplicity for both web and ftp services running on W2K and XP.

donquixote is correct Windows Vista does support symlinks using the mklink from command prompt, see

I have not as yet used Windows 7 it apparently also supports the mklink command, see

donquixote’s picture

I guess you can NOT copy the Windows symlinks to a Linux server via FTP - am I correct?

cpotter’s picture

Thank you for this valuable resource. However I have an issue :

I had one site already set-up (with settings.php in the default dir).

I wanted to add another site with a new domain. I created the directory in /sites. Write a settings.php with the new database info in it.

However when i enter , Drupal says :
Drupal already installed

To start over, you must empty your existing database.
To install to a different database, edit the appropriate settings.php file in the sites folder.
To upgrade an existing installation, proceed to the update script.
View your existing site.

It seems that Drupal is not looking in the newdomain directory but uses the default one.

Any help really appreciated. I am not a tech guy but I love Drupal and would like to use it for 2 sites

Best regards,

ps: if I remove the default/settings.php, Drupal raises an error (I don't understand this, it seems that Drupal is *not* looking in the subdirectory for the settings.php

pkeyes’s picture

I'm having the same issue--Drupal is not looking at the settings.php file in my sites/ directory, instead it's taking the default/settings.php directives.

I have the site set up via sym-links from the root webserver directory--the directory structure is like this:

total 48
-rw-r--r-- 1 user www 57 Dec 9 11:15 xmlrpc.php
-rw-r--r-- 1 user www 56 Dec 9 11:15 index.php
-rw-r--r-- 1 user www 57 Dec 9 11:15 update.php
-rw-r----- 1 user www 1590 Dec 9 11:15 robots.txt
-rw-r--r-- 1 user www 58 Dec 9 11:15 install.php
-rw-r--r-- 1 user www 55 Dec 9 11:15 cron.php
lrwxr-xr-x 1 user www 18 Dec 9 11:17 modules@ -> ../drupal/modules/
lrwxr-xr-x 1 user www 17 Dec 9 11:18 themes@ -> ../drupal/themes/
lrwxr-xr-x 1 user www 15 Dec 9 11:18 misc@ -> ../drupal/misc/
drwxr-xr-x 3 user www 512 Dec 9 13:06 sites/
-rwxr-xr-x 1 user www 9478 Dec 9 13:17 settings.php*

pkeyes’s picture

Just found solution here:

Since I'm using a subdirectory structure, i.e., '', '', I just created the directories in the core drupal installation (drupal/sites) with the directory names, 'drupaltest' and 'drupaltest2'. What I needed to do was name the directories with the complete URL, subsituting a '.' for the '/'. So the sites subdirectory is name '', rather than just 'drupaltest'

Dr. DOT’s picture

Early on in the setup instructions above the following statement is made (first paragraph after Directory/Contents table) "Configure Drupal site settings to specify 'File System Directory' of 'sites/' instead of the default 'files'."

What exactly needs to be done here? I looked in the settings.php document and there is nothing obvious in there that contains any such settings for the "File System Directory".


Lk2’s picture

If you have more than 2 sites on your Drupal installation, you may want to have modules/themes installed only in a group of sites (not only in one and not in all of them). Is there any way to do this in Drupal?

I would do it using symlinks, for example:

$DRUPAL_DIR/sites/common/modules/ .... (directory where modules are)

$DRUPAL_DIR/sites/ (symlink to the module in the other directory)

Vasu’s picture

I have few domain names registered with .com, .net, etc. I have not decided which one will be used finally (e.g. or Is it possible to create the site directory without domain extension like 'sites/example' instead of sites/ , so that if I decide to change the primary domain from to i don't have to chage the sites/directory name.

guigui_nyc’s picture

just need to add a symlink to point to example.
We just did something similar to prepare a migration to drupal: our old website is still running (not on Drupal). So in order to test the futur Drupal website, we set up another domain However since one day we'll switch the current website to Drupal, the domain will no longer be beta.... but
==> since we don't want to rename all the path from beta to normal when we go live, right now the drupal folder is and there is a symlink to point all requests from to the folder.

Jumoke’s picture

Thanks for this great post. This is very similar to what i am trying to do, the only difference is that my drupal is not installed in the root, mine is a level above that (it's in same level as public_html) and i'd like to keep it this way and so my directory is as follows:


I have created a subdomain.
I'd still like my live site to keep live with its static page for now and point my to my drupal installation. Once we are ready to go live, i'd change to to exactly like you did. Can you tell me how to accomplish this like you did above for your folder? thank you.

Katharine_Gates’s picture

I have a multisite install on my local for development -- several clients, separate databases, single drupal install.(MAMP stack) Works great. Unfortunately, I named my directories

drupal/ (core modules etc here)
drupal/sites/site1 (site 1's modules and themes in here)
drupal/sites/site2 (site 2's modules and themes here)nstead of drupal/sites/ and drupal/sites/

Now I am trying to upload site2 to the client's server. I have used the same architecture as on my local.

I do seem to have the database and drupal talking. Menus, text etc are coming in OK. However, drupal is not finding any of the files, modules and themes specific to site2. SO: this is probably because I didn't call it originally. Is there a fix to this? Just renaming the drupal/sites/site2 folder as drupal/sites/ is not fixing the situation... (that would have been too easy, right?)

Somewhere somehow I have to point Drupal to the site2 folder. Not sure how to do this. Noob-city but learning...

Thank you so much for your help.

karolrybak’s picture

This is quite simple you can set path in /admin/settings/file-system

However there might be some files in your db, so you might need to update the db too. Check your files table...

panayotis’s picture

I am preparing to launch some sites on a webhosting platform. So, I set up a test server (virtualbox debian lenny) and installed two virtual hosts in apache (one is for developing/testing and the other is a sandbox. My goal is building, and on my webhost and site.home, site1.home site2.home on my virtual machine. site1.home and site2.home are aliases in /etc/hosts.

In /sites I created two directories, site1.home and site2.home. Firstly I installed site.home (which resides in /sites/default). Whenever I try to install site1.home or site2.home I get stuck in step 2 i.e. I get a settings.php sites permission error. I read a lot of posts in, tried some rewrite modifications, with no luck.

Now what is puzzling is the fact, that doing exactly the same on my webhosting account (I used parked domains), I had no problem installing, and I uploaded on both servers the same drupal files and used unmodified .htaccess files. No symlinks.

Anybody has an idea what I am doing wrong?


I solved the problem by defining a virtual host for every domain. Not very elegant, but it works.

philingle’s picture


I have been asked to take over the maintenance and development of a couple of sites set up in multisite mode. Something that struck me striaght away was that some files were in 'non-standard' locations. for example, the theme being used is in
can i simply move the whole theme folder to
without any issues?

There is also a folder called
which contains folders called cache, color, css, files, imagecache etc
Should all this data not be in
and if so can i move it there easily?

I would prefer to make this site have a 'standard' setup before I start trying to work on it.



Phillip Ingle
AndrzejG’s picture

I have no SSH access to my hosted Drupal 6.19. I have only FTP access to Drupal root. How can I do symbolic links? Are these links mandatory?
(sorry, I am not a technology expert).

OK, I found :-)

AndrzejG’s picture

On the hosted server, I have the site mysite, parked on a domain
I need multisite configuration with shared database, no single sign-on.
Therefeore, I parked the domain
I organised subdirectory sites/
In this directory, in settings.php, I set a new base_url pointing to ''.

And now, when I point my browser to, and also to,
the main page of is displayed.
It seems that no new site has been created.

What should I do additionally?
Probably I have to set prefixes, however, the only instructions are available on shared users' tables, and it is not what I need.

OK, finally I found proper solution for my project (Domain Access). Thanks for support.

iantresman’s picture

I have multisite working great.One change I'd like to see, is the prevention of sites being able to access another site's site/domain folder. eg.

  • domain1 can access:
    • sites/all/*
    • sites/default/*
    • sites/*
  • But domain1 should not be able to access
    • sites/*
    • sites/* etc


  • domain2 can access:
    • sites/all/*
    • sites/default/*
    • sites/*
  • But domain2 should not be able to access
    • sites/*
    • sites/* etc
joelcollinsdc’s picture

block them using apache:

  <Directory /var/www/active/vhost/>
    <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteCond %{REQUEST_URI} sites/(.*)/files
      RewriteCond %{REQUEST_URI} !sites/examplecom/files
      RewriteRule ^ - [F]
iantresman’s picture

I'd also like to see simpler URLs for accessing site/directory content. eg.
To access an image I have <img src="sites/">
It would be neater to have <img src="files/images/picture.jpg"> which automatically looks in sites/

2dareis2do’s picture

Does anyone know of a script or module to help with moving a single site setup to multisite?

i.e. most of the paths are currently broken as I have moved everything from

1. sites/all to sites/
2. sites/default/files - sites/

I guess some of these are in the stylesheet but there are quite a few in various content types as well as other configuration options.

Freelance Web Design and Development

iantresman’s picture

I used the Search and Replace Scanner module to search for file paths, and replace with new ones. It can potentially trash your site further, but you can preview changes before committing them

2dareis2do’s picture

Have tried the scanner module now and works a treat.

Freelance Web Design and Development

BarisW’s picture

After moving modules and themes to another directory, visit admin/build/modules to re-scan your directories. You can also do a search/replace query in you system table (using phpmyadmin for example). After you modules and themes have been refound, you have to update your files table (only for Drupal 6, Drupal 7 doesn't store the files path anymore in the database).

You can do this by running a query like
UPDATE files SET filepath = REPLACE(filepath, 'sites/default/files', 'sites/');

Good luck!

Baris Wanschers (@BarisW)
Drupal specialist

2dareis2do’s picture

Thanks for the useful query. Have used the scanner module for now.

Freelance Web Design and Development

mackm’s picture

I've just migrated my D& site from single site (sites/default) to a multisite configuration (sites/ and everything is working fine except all my image URLs are still referencing the now non-existent sites/default/files/styles/...

Any help as to where to look to update this D7 path?


iyiwebci’s picture

I agree and thank you for sharing ideas.

doublejosh’s picture

Not 100% certain why there is a preference not to have a sites/all/files folder and go with sites/default/files. Is this a somewhat arbitrary convention or am I missing something?

To be clear, this is in order to have files available to all multisites (whether user uploaded or source controlled things.)

djmolny’s picture

It's a security issue.

Let's say you have two domains, and, and that authenticated users of can access Anyone could access the same file via Not good!

In addition, you'd have to make sure that there was no duplication of filenames across sites.

-- DJ

V I R U S’s picture

One question:

For example i have a custom-written module named "test" which is placed in /sites/all modules
But for a single domain, i would like to customize this module a bit, so i copy it to /sites/ and change it the way i like.

Which one of "test" modules, from "all" or from "" will be called if i visit website?

/* XTreme-CStrike */

gilsbert’s picture

Hello all.

On my company we use drupal with multisite installation using at same time subdomains and subfolders.

We used the rewrite rules below for the files directory (tested with apache).

--> begin
RewriteEngine on

# Lembtre: para redirecionar a requisição para a localização física do arquivo mude [L] para [L,R]
# Remember: to redirect the URI to the actual location of the file change the [L] to [L,R]

# Drupal7 múltiplos sites utilizando subdomínios e/ou subpastas!
# Redireciona a pasta "files" para que seja possível utilizar urls curtas.
# Drupal7 multiplesites using subdomain and/or subfolders.
# Redirect the folder "files" allowing the use of short urls.

# Redirecionamento para sites em subpastas.
# Redirecting for subfolder sites.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}<>%{REQUEST_URI} ^(.*)\/files\/(.*)<>\/(.*)\/files\/(.*)
RewriteCond %1\/sites\/%{HTTP_HOST}.%3\/files -d
RewriteCond %{REQUEST_URI} ^\/(.*)\/files\/(.*)
RewriteRule ^(.*)$ \/%1\/sites\/%{HTTP_HOST}\.%1\/files\/$1 [L]

#Redirecionamento para sites em subdomínios.
#Redirecting for subdomain sites.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} ^(.*)\/files\/(.*)
RewriteCond %1/sites/%{HTTP_HOST}/files -d
RewriteRule ^(.*)$ \/sites\/%{HTTP_HOST}\/files\/$1 [L]
--> end

When the site is a subfolder (host/subfolder) the first part of the rule is used.
When the site is a subdomain ( the second part of the rule is used.
You must note we removed the part about redirection for "default site" when the "files" folder is not found. If you want it back you must adapt the rules!

With this rewrite rule setting it was possible to use a simple "files" as the public filesystem root on each site. But this was not a dream, see below.

About the relative paths!

We got the best results from subdomain sites (all relative links to media content were simplified to /files/name-of-file.extension instead of /sites/www.subdomain.domain/files/name-of-file.extension).

But for subdirectories we could not find how to change the default behavior of drupal.
In fact we dont know it it was possible: we tried to setup drupal to complete the relative links using the subdirectory information with no success. If drupal can do that then the solution will be perfect for both conditions and sites can be safely migrated from subdomain to subdirectory system (as far we could note drupal uses the subdirectory information on the relative link... not good for migration).

Well, pathologic could be used but this module works perfectly in case the same site is used in subdomain and/or subdirectory in different servers, but not when the site is used in subdirectory and subdomain in the same server - at least I could not make it work (yes, kind "freak" setup but it is necessary for my company).

With no good solution, we are now using only subdomain and hoping for good news in the next releases of drupal!

Later we found another limitation on rewrite solution: the imce module (file browser integration to drupal)! We dont know why but imce just doesn't work with rewrite rules (we believe it requires direct access to the file system and dont use apache rules to decide how to solve an url... at least it makes some sense).

The imce limitation forced us to abandon the rewrite solution!

For imce integration now we are using the symbolic link solution (each site has a symbolic link at drupal root pointing to the correct "/files" directory, for example a symbolic link "files-site1" pointing to sites/www.domain/site1 or "files-site2" pointing to sites/www.site2.domain). The public file system of each site is different but relative paths produced by drupal (filefield for example), ckeditor and imce are all equal and working.

So this comment is just a sharing experience, hoping to be useful for someone!

Gilsberty Boscolo