
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.
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/settings_custom_url.inc';
/**
* Add the domain_conf() settings override.
*/
require_once './sites/default/modules/domain/domain_conf/settings_domain_conf.inc';
/**
* Add the domain_prefix tables.
*/
require_once './sites/default/modules/domain/domain_prefix/settings_domain_prefix.inc';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.
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...
17 Comments
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 example.com | myexample.com | my.example.com as legal names, so I do not understand the issue.
-
Ken Rickard
Senior Programmer
Palantir.net
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 path.example.com 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?
Thx.
J.
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 http://drupal.org/node/200066. 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.
Michael
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.
C
great tutorial, but I have a
great tutorial, but I have a frustrating issue with domain access installation, pls see here http://drupal.org/node/631474#comment-2263118
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 installed Domain
Hi,
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?
Will this diminish the value
Will this diminish the value of the site by sharing the content or wont it matter as they are 2 separate domains.
thanks my teacher.
thanks my teacher.
Thanks for info..
Thanks for info..
Hey I just wanted to let you
Hey I just wanted to let you know, I really like the piece of writing material on your site. But I am employing Chromium on a machine running version 9.10 of Crashbang Ubuntu and the UI aren't quite satisfying. Not a strong deal, I can still essentially read the articles and research for information, but just wanted to inform you about that. The navigation bar is kind of challenging to apply with the config I'm running. Keep up the great work!
muhabbet
indir
oteller
Will this method work on
Will this method work on linux based hosting?
Post new comment