Multiple Domains for one website

August 30, 2014 2.9k views


I want to have 1 drupal site with 2 domains i.e. .com

I have setup my dns for the .com just the basic dns setup and pointed the domains at the DO nameservers. The .com is now resolving but the which I have also created dns for does not resolve.

I have tried to add vhosts file to the apache server but this has not worked.

PLease any help or suggestions would be greatly appreciated.



1 comment
  • I am still figuring out the best approach for this kind of thing, but I have managed it two different ways:

    1. use the 000-default.conf file for the first domain (rather than creating a separate conf file) ..this makes that domain the default website, and unconfigured domains will point to that site

    2. A different approach I have done is to set up a conf file for the second domain, and then in that directory for the second domain I put an .htaccess file that redirects to the first site. The .htaccess file has this in it:

      <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteCond %{HTTP_HOST} ^$ [OR]
      RewriteCond %{HTTP_HOST} ^$
      RewriteRule (.*)$$1 [R=301,L]

    Of course, if your is not resolving at all, it might just need a little more time if you have only recently made DNS changes.

4 Answers

Since you mentioned this in the LAMP category the easiest way to do this is to point the domains to the same IP address.

Then inside of your VirtualHost just add the following:


And you're all set!

  • @moisey,

    Thanks for the reply this is the method I used in the end.

    The main issue I was having was slow DO dns propagation so only one of my domains was returning an answer when digging the domain.

    But I think that this is the best way to get multiple domains pointing at 1 IP.

  • That is the simplest and easiest way to serve multiple domains from the same virtualhost.

    We are also in the middle of a large rebuild of our DNS system, we are testing it in the background now, once we roll it out in a few weeks it will greatly speed up DNS propagation. It will be instant, where as now it takes a few minutes.

    We're also looking into supporting user defined TTL values for records as well as part of that update.

  • do i have to setup something on my DO panel? i have pointed bot domain name servers to digital ocean and i have added the .com and as server alias

    but only the .com is working, is there anything else i have to do? set up a cname or domething?


I would like to extend this question with another detail: how will this work in case the 2 domains are secured with (different) ssl certificates?

thank you.

my idea is to have 2 very similar .conf files for both domains and only the certificates to point to their specific location. In my case it is about startssl certificates.
I will give it a try...

without ssh is working. I will work to get the second start ssl certificate and to try also with it.

Have another answer? Share your knowledge.