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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With