I am new to Apache web server. When we configure Apache web server, we have the options of setting name-based virtual host
.
Based on my understanding, when a user type in a domain name www.example.com
in a web browser, it will connect to a DNS server which will convert the domain name to a (public) IP address. Then, the web browser will connect to the web server using the IP address.
Now, let's say I have a server with a public IP address, a.a.a.a
. I have registered 2 domain names, www.example.com
and www.example1.com
. Both of these 2 domain names are pointing to the same IP address, a.a.a.a
. So, when user types in www.example.com
or www.example1.com
in his web browser, the DNS server will point them to the IP address a.a.a.a
.
I have configured name-based virtual host according to the user guide at this web site.
However, what I don't understand is: Since the DNS server already converted domain names to IP address, all users will connect to the web server using IP address a.a.a.a
. How Apache knows whether the user is using www.example.com
or www.example1.com
in their web browser?