Alias one set of Subdomains to another

Schneems asked:

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

When I visit I want to see the content on 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 domain to point to will make any subdomain of point at instead of the associated subdomain. I.e. would reference instead of

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

My 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.

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.