Map CNAME a subdomain to other subdomain on droplet

Posted July 29, 2014 8.7k views

I am hosting 2 domains on one centos droplet. And I want to alias subdomain of domain one to a subdomain of domain two. Like this.

I want to use as alias to, so that shows content of
How to do that.

I have added this in DNS section of
CNAME subdomain

But it’s not working. points to error page. It should show website on

1 comment

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

The CNAME record should look like this (on points to error page

Can you post the exact error you get?

Yes, that’s what I did. in DNS section of added CNAME entry


But shows default centos/apache page.

I have also waited an hour, thought DSN might not have propagated so far. But it’s same result.

  • That’s fine, it means the subdomain is pointing to your other droplet. The next step is to configure Apache to serve the contents of when a request for hits it.

    To do that, open your VirtualHost config file in your favorite editor and add the following line under ServerName


    If you already have a ServerAlias directive in your VirtualHost config, simply add to the existing alias(es) separated by a space:


    Finally, restart Apache2 for the changes to take effect:

    sudo service apache2 restart
  • That was it.
    It’s working now.

    Thanks a lot.