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 (http://support.launchrock.com/knowledgebase/articles/36694-creating-your-cname-record-godaddy), I create a CNAME record as


with the value


I understand that folks accessing signup.mysite.com would be redirected to sites.launchrock.com, but I'm trying to understand how sites.launchrock.com 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 bit.ly allow anyone to use cname.bit.ly as their CNAME? - but this did not explain how to serve different content to different domains.

1 Answer 1


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 http://foo.example.com/?q=baz into your web browser, the host header would contain foo.example.com. 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.

  • 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, 2011 at 6:12
  • Any idea of what I would have to do to 'pass' that host header parameter to my script?
    – siliconpi
    Dec 22, 2011 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, 2011 at 3:52
  • Ahh [slaps hand on forehead] - that makes sense!
    – siliconpi
    Dec 22, 2011 at 4:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .