Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am running app on mydomain.com, when abc customer ask for instance of my app, I create a subdomain (like abc.mydomain.com) and put copy of app to that subdomain. That's fine.

When abc ask for their own domain like "abc.com", I need to point abc.com to abc.mydoamin.com.

How do I do that ? My app is in php app runs on apache2.

I need to do this using CNAME recode

I tried putting CNAME recode to abc.com zone file to point abc.mydomain.com, But it doesn't show the content of abc.mydomain.com. It shows Apaches default page ("It Works").

IN NS ns1.mydomainserver.net;
   @ IN CNAME abc.mydomain.com;

What is the wrong with this? Is there any way to do this with-out touching vhost files on apache?

share|improve this question
What domain is your Virtual Host set up to respond to in Apache? –  Hyppy May 18 '11 at 13:02
One note on handling CNAMEs: as a CNAME record will be valid for any RR type (not just A, but also TXT, MX and NS records), it should be avoided for RRs which will contain anything but the CNAME - like the record for abc.com in this case. Use an A record with the same destination IP address as abc.mydomain.com instead. –  the-wabbit May 18 '11 at 13:18

3 Answers 3

You need to add an alias in the Vhost-config in Apache.

<VirtualHost ip1 ip2>
   DocumentRoot /www/abs
   ServerName abc.mydomain.com
   ServerAlias abs.com
share|improve this answer

You need the following to allow your app work with abc.com

You need to have a CNAME record for the abc.com domain that points to mydomain.com.

You need to create a ServerAlias in your apache config, with abc.com

The first will have to be done by the owner/administrator of the abc.com. The second should be on your own server.

share|improve this answer

If you're not able to edit the virtual host entry for your abc.mydomain.com website (and that's the best place to do this; see the other's posts), you'll need to do a redirect somewhere:

  • abc.com's DNS "control panel" may have a "Web Redirect" type option you can do.
  • at abc.com's webserver (if it's setup/hosted somewhere), you can set the webserver it return HTTP 301 or 302 and abc.mydomain.com (both Apache and IIS can do this)
  • you can put an index.php with header('Location: http://abc.mydomain.com/');
  • if PHP is not available, you can do a <meta http-equiv="refresh" content="0;url=http://abc.mydomain.com/"> but this is not recommended.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.