Fri April 19 2024
Learn  |  Reference  |  Code Base  |  Solutions  |  Freelancing  |  Tips & Tricks  |  Downloads  |  Reviews  |  Affiliate  |  Make a Donation  |  Home
Name-based Virtual Hosting
Name-based virtual hosts use multiple host names for the same webserver IP address.

With web browsers that support HTTP/1.1 (as nearly all now do), upon connecting to a webserver, the browsers send the address that the user typed into their browser's address bar (the URL). The server can use this information to determine which web site, as well as page, to show the user. The browser specifies the address by setting the Host HTTP header with the host specified by the user. The Host header is required in all HTTP/1.1 requests.

For instance, a server could be receiving requests for two domains, and, both of which resolve to the same IP address. For, the server would send the HTML file from the directory /var/www/user/Joe/site/, while requests for would make the server serve pages from /var/www/user/Mary/site/.

Example: A blog server can be hosted using Name base hosting. and

If the Domain Name System (DNS) is not properly functioning, it becomes much harder to access a virtually-hosted website. The user could try to fall back to using the IP address to contact the system, as in The web browser doesn't know which hostname to use when this happens; moreover, since the web server relies on the web browser client telling it what server name (vhost) to use, the server will respond with a default website�often not the site the user expects.

A workaround in this case is to add the IP address and hostname to the client system's hosts file. Accessing the server with the domain name should work again. Users should be careful when doing this, however, as any changes to the true mapping between hostname and IP address will be overridden by the local setting. This workaround is not really useful for an average web user, but may be of some use to a site administrator while fixing DNS records.

Another issue with virtual hosting is the inability to host multiple secure websites running Secure Sockets Layer or SSL. Because the SSL handshake takes place before the expected hostname is sent to the server, the server doesn't know which certificate to present when the connection is made. One workaround is to run multiple web server programs, each listening to a different incoming port, which still allows the system to just use a single IP address. If running multiple web server programs is considered clumsy, a more efficient solution is to select TLS (TLS 1.1 or later, which enables name-based virtual hosting as of June 2003, documented in RFC3546, and updated in RFC4366). Another option is to do IP aliasing, where a single computer listens on more than one IP address.