Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have several sub-domains on 1 website

I've also registered equivalent domains for each of these sub-domains at

How can I set it so that when someone types the domain, they see the content from but still see as the URL. So the content is really served from without the visitors knowing that.

share|improve this question

migrated from Sep 7 '10 at 2:01

This question came from our site for professional and enthusiast programmers.

4 Answers 4

This is kind of multi-layered.

Firstly, you need to setup a CNAME record for to point to This is done via whoever is hosting the DNS for You should more than likely have a control panel at either your hosting company or your domain name registrar to add this.

All this does however is tell clients that your website lives at a certain IP address (i.e. in the case of a CNAME, it says, look up the IP of and lives at the same location.)

Secondly, you need to tell your webserver that and are the same site.

For Apache, you probably already have a <VirtualHost> setup, so you would add in a ServerAlias directive to tell Apache that the VirtualHost also serves as well as

... signifies that you have your own configuration directives in here already.

<VirtualHost ...>

Thirdly and lastly, you need to make sure that your site doesn't redirect or reference within the code (i.e. Header redirects through PHP, meta tag refreshes, or a href links within the HTML to redirect the user outside of the current domain).

Links should have absolute paths without the domain, e.g. 1 not 2


<a href="/blah.html">Blah</a>


<a href="">Blah</a>
share|improve this answer

You need to have the domains point to the same server of the subdomains, and using your hosting control panel set the domains as aliases to the subdomain.

p.s. asking those questions on gives you much better feedback, since that is the place to ask such questions.

share|improve this answer

You will need to add a CNAME entry to your DNS zone. However you might need to adjust some login in your code if its dependent on requested host, cause your scripts will not see but, so adjust them accordingly to handle both cases.

share|improve this answer

Sounds like you want a "Frame Redirect":

share|improve this answer
This won't work for embedded images/css/js.. – aularon Sep 7 '10 at 0:56
Ugh, there are soooooo many better ways of doing this – Mark Henderson Sep 7 '10 at 4:53
Fast, good, cheap. Pick two. – Rob Olmos Sep 7 '10 at 5:00

Your Answer


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