Sharing Content with Domain Access

By Marc Ingram | Filed Under: Drupal, modules

We were recently approached by a client who wanted to create two sites to serve different audiences but with vast amounts of common content. The same group of people would be responsible for the upkeep of both sites and the desired solution would allow content to be shared with great ease.

We initially considered a Drupal multisite install, but the idea was rejected in favor of the Domain Access module. The rationale was simple: with a traditional multisite configuration, we would have had to create custom code to determine where content would be displayed, whereas this is the primary functionality provided by Domain Access. The other attractive element was having both sites on the same code base, with the creation of additional sites handled via the Drupal database itself.

The build strategy

We began by creating a standard Drupal install and adding menus and content as if we were creating a single site. Domain Access can be added at any point in time, and all existing content will remained published on the domain served by the existing site. This means that no rework was required, and it allowed us to deliver the client's requirements in a phased manner. Once we were comfortable that the initial work was completed, we introduced Domain Access, which requires some updates to the settings.php for proper operation. These changes can be made before or after the module has been enabled:

* Add the custom_url_rewrite_outbound() function.
require_once './sites/default/modules/domain/';

* Add the domain_conf() settings override.
require_once './sites/default/modules/domain/domain_conf/';

* Add the domain_prefix tables.
require_once './sites/default/modules/domain/domain_prefix/';

Configuring Domain Access

Domain Access ships with a number of modules and, for the suite to be useful, a number of them need to be configured. What we found as the minimum required for the commonest functionality is shown below.

This setup allows all the sites to have their own configuration settings, site-specific Views, themes and, where required, unique database tables. To create additional domains, visit admin/build/domain/create. You'll note that you're asked to enter a subdomain rather than a domain -- while Domain Access only supports subdomains, the issue can be overcome with some Apache configuration magic (more on that later). Now that you have a domain created, visit admin/build/domain/view to configure your new domain. The operations presented will depend on the modules you have enabled; most relate to standard Drupal site configuration.

One significant exception is the "Table prefixing" tab, which allows you to setup different tables for different domains in cases where you don't want the data to be shared. For example, our client wanted separate menus on both sites, so we opted not to share the menu and cache_menu tables. When we created the new tables, we than chose to copy the existing table because the second site's navigation was a subset of the first. Had this not been the case, we could have just created a new table rather than copying it. Of course, you'd then have to login to the appropriate subdomain to edit the relevant menus.

Content creation

Once Domain Access is installed, content creation offers a few new options which allow you to determine which domain items appear on. Content can be added and removed from a domain with the same ease as content being published or unpublished by Drupal itself. Similarly, content can be processed on a batch basis by visiting admin/domain/content/all.


Once development has finished, you're ready to deploy your new site. Launching a site utilizing Domain Access is the same as a single site install with one exception: you'll need the ability to update Apache's VirtualHost configuration and, depending on your hosting company, you might not have it. Remember: whenever you need to deploy a site using this design pattern, always check with your hosting provider to see if they can support your requirements. As a general rule, you'll need to add either all Domain Access configured domains to the primary VirtualHost's ServerAlias, or else point all relevant DocumentRoots to your single installation of Drupal. Once these changes have been made, your new site(s) will be live and you can freely share content between them with just the click of a button.

Until next time...


Hi, we followed this example

Hi, we followed this example in our installation of Domain Access, everything seems fine, except where do we set up DocumentRoots? We have single Drupal installation and configured Domain Access according to your example. We added subdomains via Domain Access, but now are a bit stuck not having access to VirtualHosts... Where and how do we set up the DocumentRoots? Thanks!

I am a little confused by

I am a little confused by this assertion:

You'll note that you're asked to enter a subdomain rather than a domain -- while Domain Access only supports subdomains, the issue can be overcome with some Apache configuration magic (more on that later).

DA supports | | as legal names, so I do not understand the issue.

Ken Rickard
Senior Programmer

I think the confusion is

I think the confusion is brought about by the instructions on the create domain page. Where the description provided states.

The allowed subdomain, using the full format. Can only contain lower-case alphanumeric characters. Leave off the http:// and the trailing slash.

If we can in define domains directly rather than having map a domain to a subdomain via the VirtualHost configuration file then that makes this module much simpler to configure, which is wonderful news.

Great article and

Great article and information. It would be more helpful with the images not broken though... I'll check this page again (e-mail to me would be nice too...)

How did you handle metatags

How did you handle metatags for several domain as part this the launched strategy? I have implemented DA and it works well, however I am not sure how best to implement metatags for each domain - they need to be different - without just including them in the themes themselves. Ideas?


Followed the example, and

Followed the example, and have one question. How are you able to log in? I am always redirected to the default domain whenever I log in from a subdomain, and the login never seems to "take" - If I then manually enter the /admin url of the subdomain page after a login attempt, Drupal still says I need to log in.

Hello Kamau, I'm having the

Hello Kamau,

I'm having the same issue as the one you've describe above. Have you found a fix for this yet? I initially thought Domain User was the answer but it has nothing to do with fixing this. Let me know, if you still check this article.

Great write-up by the way. :)

Hi Daglees, See

Hi Daglees,

See This describes that setting $base_url manually in your settings.php will generate this behaviour. The best option is to leave $base_url unset in your settings.php (commented out) and let Drupal determine the appropriate value.


This might be a silly

This might be a silly question

i have created my main site
I want to create a subsite
I see that I can create the dns entries, etc using domain module
but do I create a whole new drupal site in my db or should I share tables?
how would I do this? I read somewhere that this is a multisite configuration rather than a domain access one.

any help in clarifying would be helpful.


great tutorial, but I have a

great tutorial, but I have a frustrating issue with domain access installation, pls see here
any help is appreciated

In the article you said "We

In the article you said "We initially considered a Drupal multisite install, but the idea was rejected in favor of the Domain Access module."

Does this mean that the two can't be used together?

I would also like to know how essential the Domain Views module is to content sharing across sites. I recently tried to use the Domain Access module across 5 multisites and when trying to activate the module notice that the Domain Views component is missing, and everytime I try to publish content across my sites the content does not appear on the site that I choose to publish the content to (I should also mention that this is being done on a localhost in a XAMPP install).

Do you know what could be the cause of this?

hi i have same problem plz

hi i have same problem plz help me

Hi, I have installed Domain


I have installed Domain module in order to achieve multisite feature. Created 2 domains and created content specific to the two domains. When i see the sites separately, i can see all contents not only the contents specific to the site. Any idea why this is happening?

you stated up front that the

you stated up front that the sites would share vast amounts of content. I'm in a similar situation, but am fearful of the dreaded duplicate content penalties from Google. Basically I want different skins shown to anonymous users based on the referrer. Suggestions?

have been trying to bring DA

have been trying to bring DA online.

tried adding the lines memtioned above to my .sites/default/settings.php

get the following
( ! ) Fatal error: require_once() [function.require]: Failed opening required './sites/default/modules/domain/' (include_path='.;C:\php\pear') in C:\wamp\www\drupal-7.0\sites\default\settings.php on line 463
Call Stack
# Time Memory Function Location
1 0.0004 369504 {main}( ) ..\index.php:0
2 0.0059 914224 drupal_bootstrap( ) ..\index.php:21
3 0.0060 913896 _drupal_bootstrap_configuration( ) ..\
4 0.0061 917984 drupal_settings_initialize( ) ..\
5 0.0070 927040 include_once( 'C:\wamp\www\drupal-7.0\sites\default\settings.php' ) ..\

Get the same error whether I place the lines at the beginning or the end of the file.

tried changing the file paths from ".sites/default/" to ".sites/all". got the same problem.

Any thoughts?

Check the actual location of

Check the actual location of that file "", it's located within the domain access module, which you may have placed in either sites/all/modules or sites/default/modules. The path needs to match. If all else fails, try setting an absolute path like "C:\wamp\www\drupal-7.0\sites\default\modules\domain\" in settings.php.

Thanks for your

Thanks for your input!

Solution was combination of path alignment as you said and finding the install instructions for D7 version

I'm convinced that DA will work like a charm when all the virtual host issues are completed. Tests on one sub-D indicate so. Well worth the DNS management overhead. Assignment processes for content, themes, etc can be handled as training issues.

Only issue remaining is "Single Sign On"

Hi David, If they're

Hi David,

If they're subdomains E.g. and, you can use the $cookie_domain variable in settings.php.

$cookie_domain = '';

Notice the leading period.

Otherwise (no D7 release at this stage).

Hope this helps,

I would like to know how to

I would like to know how to use domain access with fully qualified domains (not subdomains). It's mentioned in the article as "More on that later" through "Apache Configuration Magic" but never elaborated on. Any information would be appreciated.

Please...If you make video

Please...If you make video presentation?

Hey! Can we share entities in


Can we share entities in drupal 7? i can't figure out to manage them

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.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options