views:

34

answers:

2

Hi,

I 've this little doubt but I couldn't find information about it, probably because I'm not searching the correct thing.

When a browser ask for "www.mydomain.com", the DNS server returns an IP Address, then the browser go there... but what does happen then? I mean, that IP address could be a shared hosting that contains hundreds of web pages and domains, so how does it knows where it have to go?

Is something that the web server does? is it something that I could implement in a web application?

I mean, for example I have a web application that contains accounts, and each account has a default web page. You could access that page passing the account namne, for example "www.mydomain.com/myaccount", but now I want to register "www.myaccount.com" and then it will get the "www.mydomain.com/myaccount" content. Is it possible?

Kind regards.

+2  A: 

The webserver handles which application responds to your request. Your "shared hosting" has another name. It's called "virtual hosts". The webserver has a list of "virtual hosts" and depending on how you got to the host (via what hostname), the web server picks which application responds to your request.

xyld
I guess that the web server will reject any request to a Host that is not in its "virtual host" list, is there a way to force it to accept all? or am I suggesting something mad? :D
vtortola
Typically, it accepts all requests unless you've defined "virtual hosts". Usually there is some kind of default handler.
xyld
do you have any information about that or could you tell me what should I look for? Thanks!
vtortola
+1  A: 

HTTP/1.1 requires that all requests include a Host header which includes the domain name that you typed in. So a basic request for "http://www.example.com/foo/bar.html" will look like this:

GET /foo/bar.html HTTP/1.1
Host: www.example.com

And the web server will then be able to use the Host header to route the request to the correct website, even if there's more than one on the same IP address.

Dean Harding
I guess that the web server will reject any request to a Host that is not in its "virtual host" list, is there a way to force it to accept all? or am I suggesting something mad? :D
vtortola
It depends on the server (e.g. Apache vs. IIS, etc) how you actually set it up but you can have a "catch-all" host, yes.
Dean Harding
Do you know what I should look for to configure IIS7 to do that? the name of the parameters, or the technique... something :D . Thanks.
vtortola
Right-click on the website, choose "Edit Bindings" and set the "Hostname" to the host name you want it to match.
Dean Harding
Ah great, thank u :)
vtortola