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

I have to domains that I want to effectively mirror one another on select subdomains. Let's say they are pirates.com and ninjas.com and i want ninjas to mirror the content on pirates.

When I visit foo.ninjas.com I want to see the content on foo.pirates.com. Due to app restrictions I need to do this in DNS for an undefined number of subdomains. I was under the impression i could do this with a CNAME, but it appears that setting a CNAME for * subdomain of the ninjas.com domain to point to pirates.com will make any subdomain of ninjas.com point at pirates.com instead of the associated subdomain. I.e. foo.ninjas.com would reference pirates.com instead of foo.pirates.com.

Is there a way to do this using DNS? Am I missing something basic?

share|improve this question

2 Answers 2

If you control the DNS server, and if it uses zonefiles, you can make both domains use the same zonefile.

An example for bind:

zone "ninjas.com" IN {
    type master;
    file "master/ninjas.com.zone";
};

zone "pirates.com" IN {
    type master;
    file "master/ninjas.com.zone";
};

I use this technique to make ~2500 domainnames look exactly the same :)

share|improve this answer

DNS is only one part of the story. The web server must be aware of the domain names that you intend to use. So you will have to set up the names in the web server as well (e.g. using Apache's ServerAlias directive.

share|improve this answer
    
So you're saying that the CNAME part should be working correctly that foo.ninjas.com should be pointed at foo.pirates.com but i have to change my server config on pirates? –  Schneems Nov 9 '12 at 23:47
    
Correct. Unless the web server knows what to do with foo.ninjas.com then it will just serve the default virtual host, which is probably a test page. –  Michael Hampton Nov 9 '12 at 23:48

Your Answer

 
discard

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.