Home / Blog / Simple "Multisite" on Drupal and Pantheon with Domain Access

Simple "Multisite" on Drupal and Pantheon with Domain Access

1. Introduction

In this guide we will set up simple Drupal "multisite" using the Domain Access module. 

Domain Access is a Drupal module which allows Drupal to load different content access permissions and serve different settings depending on the domain (URL) one accesses the site by.

This is useful for simulating multiple websites running on top of one codebase. Examples of this include:

  • Separating created content by which domain it was created on
  • Showing different themes or blocks depending on the domain
  • Setting different frontpages per domain 

These two “websites” are actually one site, running off of one codebase and database, using Domain Access to control the frontpage, blocks and theme.

Despite the title of this post, Domain Access is not "true" multisite. "True" multisite is defined as using the same codebase but different databases and environmental variables for each site, while Domain Access uses the same codebase and database for all sites (but with some differing environmental variables). This makes it possible to simulate multisite in places where traditional multisite might not be possible, such as on Pantheon (see Pantheon's blog post Drupal Multisite: Much Ado About Nothing for more information about Pantheon and Multisite)


2. Should I Use Domain Access?

Domain Access can be a great module for certain use cases, but it also comes with some potential downsides. Before using Domain Access, you should consider all the pros and cons. We mentioned some of the pros above; now, here are some of the cons and risks associated with using Domain Access.

  • Single Point of Failure: because Domain Access shares the same codebase between sites, if an error is introduced into the codebase, or if some other code problem arises, it will affect every site hosted on that codebase. In its worst form, this will bring down every site at once. This is perhaps the most risky aspect of using Domain Access. Pantheon's three-environment (dev, test, live) model makes it possible to test code and configuration changes in a safe environment before introducing them to the production environment, greatly reducing the potential risks. 
  • Greater configuration overhead: Domain Access will require greater attention paid to per-domain configurations. Every entity (all pieces of content, all users, etc.) must be restricted to their own domains. If adequate care is not taken, this may result in users or nodes being available on unintended domains. This may not be as much of a problem for some cases, but can be dangerous if an administrative user on one site finds he has unintended admin access on another site.
  • Higher server load: a major advantage of Domain Access, for many users, is the ability to host multiple websites while paying only for one actual server. This advantage can turn into a serious disadvantage, however, if the multiple hosted sites start receiving higher traffic. While your server plan may handle high traffic on one site, it may not do so well when forced to handle high traffic on two or three sites. If the server should become overloaded and crash, this will bring down all of your hosted sites, as mentioned above. 

If the above risks are accounted for, then Domain Access can be an excellent tool. However, failing to account to these risks can lead to serious repercussions down the road. Always develop responsibly!


3. How To Set Up and Use Domain Access on Vanilla Drupal 7

Domain Access is easy to set up, but requires a bit more work to enable than a standard Drupal module.

We will use Drupal 7 for this tutorial. Domain Access can also work on Drupal 6, but it is more difficult to set up. 

In our instructions, we will use example domains www.drupal1.com and www.drupal2.com. When you set it up yourself, you can use your own domains. Note that Domain Access is not limited to handling just two domains.


  1. www.drupal1.com and www.drupal2.com.com must be registered and have DNS set up to point to the same Drupal codebase
  2. A valid Drupal install. Drupal itself should be set up before beginning to set up Domain Access

If this is all correct, the two domains www.drupal1.com and www.drupal2.com should both lead to the same Drupal website, and the two domains should be functionally indistinguishable.

Now we will set up Domain Access, to introduce differences in functionality between the two.


    1. Download Domain Access, but do not enable it yet!
    2. Modify your settings.php file. You must add a single line at the bottom to include a Domain Access file.
      In Drupal 7, add this line to the bottom:
      include DRUPAL_ROOT . '/path/to/modules/domain/settings.inc';
    3. Now you may enable the Domain Access module.
    4. After you have enabled the module, you should be able to go to Admin > Structures > Domain.
      On this page, you will be able to configure the domains that Drupal "knows" about. You can set different permissions and settings based on the domains you enter here.
    5. There should already be one domain set up, the domain that you used when you enabled the module.
      We will assume (without loss of generality) that this was www.drupal1.com.
    6. Let's add a second domain.
      1. Choose Add Domain
      2. Fill out the resultant form. Enter the domain name (in this example, www.drupal2.com) in the Domain field and enter a human-readable name in the Name field.
      3. Fill out the other settings accordingly.

        The Add / Edit Domain Form

      4. Submit the form by clicking Save Domain Record


Upon completion, you will see your two domains in the Domain List

The preceding steps set up Domain Access and made Drupal aware of the two domains, www.drupal1.com and www.drupal2.com.

You can now make various content access permissions and other settings domain-dependent.


4. How To Set Up and Use Domain Access on Pantheon

Domain Access can also be used on Pantheon, but it requires a bit more setup.

We will modify our previous example for use on Pantheon.

In our instructions, we will use real example: contact.asu.edu. This site is actually many different “sites” running off a single codebase, but which appear to be separate sites due to Domain Access.

Two of the domains set up on this site are: contact.asu.edu and misc.uto.asu.edu. We will use these domains in our examples.

Note that after you set up a Pantheon site, you will by default have a Pantheon URL pointed to it, which in this example is live-contact.ws.asu.edu. This URL is already registered, pointed at the codebase and has its DNS configured. We will now configure and add contact.asu.edu and misc.uto.asu.edu.


  • contact.asu.edu and misc.uto.asu.edu must be registered and have their DNS set up to point to the Pantheon site. Because Pantheon is remote hosting, we will assume that we have not set up these URLs to point to the Pantheon codebase yet. This will be covered in the steps below.
  • A valid Drupal install on Pantheon. Drupal itself should be set up before beginning to set up Domain Access
  • A Pantheon Basic account or higher. This is required to point multiple domains at a Pantheon site.


  1. Download Domain Access and send it to the Pantheon repository, but do not enable it yet!
  2. We must modify the settings.php file. 
    In Drupal 7, add these lines to the bottom:
    extract(json_decode($_SERVER['PRESSFLOW_SETTINGS'], TRUE));
    include DRUPAL_ROOT . '/path/to/modules/domain/settings.inc';
  3. Now enable the Domain Access module.
  4. Before setting up the domains in Drupal, we must set them up in Pantheon.
    1. On your Pantheon Dashboard, go to the Domains tab.
    2. Enter contact.asu.edu and misc.uto.asu.edu in the textbox.
    3. Click the Add New Domain button. This will make Pantheon aware of the new domain and direct users going to that domain to your Pantheon site.
      Note that Pantheon will add both two URLs for each domain you enter: one prefixed with "www" and one without the www prefix.

      The Domains tab. You can see the default URL live-contact.ws.asu.edu and the two new domain names (with www and non-www variants).

  5. You may now go to Admin > Structures > Domain.
  6. Let's add a new domain for misc.uto.asu.edu.
    1. Choose Add Domain
    2. Fill out the resultant form. Enter the domain name misc.uto.asu.edu in the Domain field and enter a human-readable name in the Name field.
    3. Fill out the other settings accordingly.
    4. Submit the form by clicking Save Domain Record

      The Domain List with misc.uto.asu.edu added.

    5. We've added misc.uto.asu.edu; now it is time to add contact.asu.edu.
      We could add this as a new domain like we did with misc.uto.asu.edu. However, notice our default Pantheon domain live-contact.ws.asu.edu in the screenshot above. In our use case, we will not have any users accessing the site via this domain, and so it is rather useless. Instead of adding contact.asu.edu as a brand new domain, why not repurpose this useless domain by aliasing it as contact.asu.edu?
    6. To alias live-contact.ws.asu.edu, click this domain's "Edit Domain" link in the Domain List, and on the following screen, go to the Alias tab.
    7. On the Aliases page, enter contact.asu.edu in one of the cells of the Add New Alias table, and click Save Aliases.
    8. This will add contact.asu.edu as an alias of live-contact.ws.asu.edu. Users may now enter the site via contact.asu.edu, and experience the same settings / permissions as if they had entered via live-contact.ws.asu.edu. This can be a useful trick under certain circumstances.

      The Alias Page for live-contact.ws.asu.edu using contact.asu.edu as an alias.

The preceding steps set up Domain Access on Pantheon and made Drupal aware of the two domains, misc.uto.asu.edu and contact.asu.edu

You can now make various content access permissions and other settings domain-dependent.

5. Useful Domain Access Submodules

The Domain Access module by itself allows you to set different nodes to be available on different domains.

However, there are many submodules which extend this functionality to other things, including settings, themes, blocks, taxonomy, etc.

Some of these modules are bundled with Domain Access. Others must be downloaded separately.

Domain SettingsProvides advanced per-domain site configuration settings.Bundled with Domain Access
Domain ThemeAllows you to set different themes for each domain.Bundled with Domain Access
Domain BlockAllows you to set blocks to only be available on certain domains.https://drupal.org/project/domain_blocks
Domain TaxonomyAllows you to set taxonomy terms to be available only on certain domains. You may also use this to set a node's domain availability based on what taxonomy terms it is tagged with.https://drupal.org/project/domain_taxonomy