Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to understand how web services which have you setup CNAME records on your domain pointing to their servers work.

For example, following the instructions on LaunchRock (, I create a CNAME record as 

with the value

I understand that folks accessing would be redirected to, but I'm trying to understand how is configured so that it detects this incoming request and tailors the webpage appropriately for my landing page.

What software / configuration is present there that handles this properly?

I looked at this How does allow anyone to use as their CNAME? - but this did not explain how to serve different content to different domains.

share|improve this question
up vote 4 down vote accepted

They're using what's generally referred to as Name-based virtual hosting. For the most part, all of the widely-used web servers support this.

The nutshell version of how this works is that when your web browser connects to a remote webserver, in its request, it sends a "host" header, which contains the FQDN portion of the URL. So if you entered into your web browser, the host header would contain The web server can determine which site/application to serve depending on what host header the browser sends.

The other upside of name-based virtual hosting is that it allows site owners to serve a near-infinite number of domains off of a single IP address. That situation gets a bit more complicated if SSL is involved, but I'll leave the details of that for another answer.

share|improve this answer
Very interesting - so if I wanted to setup something like this, I'll need to specify something mapping this host name as a parameter to my script (in my httpd.conf) – siliconpi Dec 21 '11 at 6:12
Any idea of what I would have to do to 'pass' that host header parameter to my script? – siliconpi Dec 22 '11 at 3:20
You don't "pass" that last parameter to your script. You make sure that your script is running under the correct virtual host in your webserver. Your script also has access to all of the webserver environment variables, which contain useful information as well. – EEAA Dec 22 '11 at 3:52
Ahh [slaps hand on forehead] - that makes sense! – siliconpi Dec 22 '11 at 4:03

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.