Super User is a question and answer site for computer enthusiasts and power users. 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 know that dns resolves an address like to an IP address like, but I'm a little confused about how subdomains are resolved, so that when you type, what actually gets passed to the server at In other words, =, but = ???

Are "subdomain" and "path" passed as http headers, or mapped in the url in some way, or what?

Thanks in advance.

Edit: If I'm understanding correctly, BloodPhilia says that actually is a different domain that in principle could resolve to a totally different IP. But if that's so, then what about hosts that have huge numbers of (what look like) subdomains, but which actually map to some path on the site. For instance, blogspot hosts millions of blogs, and they all look like this:
...millions more...

Those are clearly not subdomains with their own IP's, but rather some mapping like -->, but how is this accomplished? What actually gets passed to the web server at

share|improve this question
up vote 17 down vote accepted

Domains, Subdomains, Sub-Sub domains, and Sub(x)-sub-subdomains (made the last two up!), are treated in exactly the same way by DNS to an end user and a webserver.

For example, the DNS server can return different results for, or

Now, as you are probably aware, there are many more domains than IPs in the world.

Because of this, servers use something known as "Host Headers" in order to serve the correct content.

It does not matter what you actually request, your machine treats everything the same - it will looks up on DNS what IP it should connect to, and once connected, it will send the host header as part of the request. The webserver then sends back the content it was configured to send back.

A good tool for testing/learning/diagnosis is Wfetch, it can be downloaded here.

Here is an example of the headers sent whilst accessing

alt text

Here is the configuation for host headers in IIS (a webserver):

alt text

(Image from here)

If you were interested, and are on the same IP and this is the technique that is used in order to separate the sites and serve different content.

For more reading on the subject, you may want to read the Wikipedia article on Virtual Hosting.

(I know you understand the basics, but I thought it would be good to say a little more so that anyone Google-ing this may learn a little if they want to!)


So, As per your example, I would guess that someone as big as blogspot most likely has a wildcard DNS entry (A wildcard entry returns the same result for any query) that points to a load balancer, the load balancer then will send it out to many different webservers who probably do not have a separate site per host header, but instead a single site/script that the address typed (host headers or not) gets parsed on, and pulls the correct content from their CDN there and then.

Although, it would also be possible (but unlikely) that they simply have a few thousand entries per ip, the ip leads to a few servers and they simply have an entry for each site that has a matching host header.

share|improve this answer
Nice! Side note: the fact that two websites share an IP address does not necessarily mean they are always hosted on the same machine. A load balancer might in fact also peek into these headers and delegate to different machines. (For Super User et al see also Stack Overflow’s New York Data Center, which I did not really read myself though...) – Arjan Jan 17 '11 at 15:56
@Arjan +1 good point... I mentioned load balancers, but it could obviously just be the IP(s) of a load balancer(s), and then they split the requests to many servers. – William Hilsum Jan 17 '11 at 15:59
Marked as answer for the detailed info and links to further researched. Thanks! – Joshua Frank Jan 20 '11 at 14:42

Indeed, if two domains have the same IP address, the server relies on the browser to specify the requested domain. Like:

GET / HTTP/1.1
share|improve this answer

Subdomains isn't the right word. Usually a subdomain is domain on its own so is passed to the DNS first, if no specific record is found for this subdomain, the request is passed to the IP of the top domain. ( On that server the request is made again and the server will act accordingly.

In other words, a request to doesn't really differ from a request to

share|improve this answer
I think maybe I am not understanding something important here. Let me edit and clarify my question. Thanks. – Joshua Frank Jan 17 '11 at 15:28
Are you saying that if does not resolve, the IP address of would be used? I think browsers don't do that. (Unless there is some wildcard DNS record, but then the subdomain would actually resolve, I'd say.) – Arjan Jan 17 '11 at 16:10 doesn't resolve to - for the purpose of your question it typically has it's own DNS A record and resolves to a different address.

It is possible to allow the subdomain resolve to the same address as the parent domain and still server up different pages, but if you do that you must host both sites on the same web server and need account for it on your server's configuration. The way you account for this depends on what kind of web server you're running.

share|improve this answer
Are you saying that, in my blogspot example, "" will have no dedicated dns entry, so dns will look for "" and find it at But it will send the whole url "" as the host field, and it's up to the server to parse this and send the xyz page to the browser? – Joshua Frank Jan 17 '11 at 15:46
Yes, that's right. – Joel Coehoorn Jan 17 '11 at 16:13
nslookup yields server can't find — how does that match the above then? (As for the example in @Joshua's comment?) – Arjan Jan 17 '11 at 20:43
sorry, you still need an A record for your subdomain - it's just that it can give the same IP if you want. – Joel Coehoorn Jan 18 '11 at 1:59
Then I'm confused again. If there are millions of subdomains, they can't all have A records, so how is the routing accomplished? And the A record configuration is server side. I'm interested in how the client would know, given a url, whether the xyz is a proper subdomain or something that's mapped server side. In particular, is it ever safe to cache an IP for a little while, because you know that and are on the same server, or can you never know just by looking at the url? – Joshua Frank Jan 18 '11 at 15:01

You must log in to answer this question.

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