How Your Server Handles Domains and Virtual Hosts
Last modified: September 28, 2020
This document explains virtual hosts and how cPanel & WHM handles them.
An overly-simplified representation of Internet hosting…
The following overly-simplified outline represents how internet hosting works:
The user requests content from a remote host at a hostname (for example, the
example.comdomain).Note:In most cases, the term domain name can act as a synonym for hostname.
The user’s computer resolves the hostname to an IP address (for example,
The user’s computer connects to the host with that IP address (
188.8.131.52) and retrieves the content.
How it really works…
Two significant factors complicate the overly-simplified outline:
Multiple hostnames may resolve to the same IP address (for example,
www.example.comare different hostnames that likely resolve to the same IP address).
A shared IP address can serve each hostname’s content as long as the user’s computer tells the remote host which hostname’s content to transmit.
To allow multiple hostnames to share content via a shared IP address, we change step 3 above. The user’s computer first tells the remote host the hostname’s content that it wants. This way, a server that hosts content for the example.com hostname can serve completely different content for the anotherexample.com hostname. This happens even though those two hostnames use the same IP address. To the user, the content seems to originate from two different hosts. Because of this, we can say that the remote host has two different virtual hosts (or vhosts) for these names.
A user who requests
example.com content and a user who requests
anotherexample.com content will receive different content. However, a host can also serve the same content for two different hostnames. For example, most users expect the same content from the
www.example.com hostname as when they visit the
example.com hostname. Therefore, these two hostnames exist on the same virtual host or vhost.
How cPanel & WHM handles web virtual hosts
cPanel & WHM streamlines how the system handles hostnames and virtual hosts in order to satisfy most common-use cases. Even though this reduces account flexibility, it guides users to generally-desirable configurations.
Every cPanel account owns at least one web virtual host that contains two hostnames:
The account’s primary domain name.
The equivalent www. subdomain of the account’s primary domain name.
So, if you create the cPanel account example with a primary domain of
example.com, then HTTP requests for the hostnames
www.example.com will retrieve the same content.
cPanel users can manage three different types of additional hostnames in the Domains group of features:
(previously Parked Domains)
A separate hostname that the virtual host associates with the account’s primary domain. For example, you can use an alias so that requests to the
anotherexample.com domain to receive the same content as the
Aliases also configure the equivalent
www. domain to associate with the same content (for example,
A hostname that uses the same domain name root as the account’s primary domain or a parked domain, but exists on a separate virtual host (for example,
other.example.com are subdomains of the
As with aliased domains, the system automatically creates an equivalent
www. subdomain of the new subdomain (
www.subdomain.example.com) in the virtual host for the subdomain.
A separate hostname on a separate virtual host. To accomplish this, cPanel creates a subdomain with the same root as the account’s primary domain (for example, for the
anotherexample.com addon domain, cPanel would create the
Then, cPanel creates the addon domain as an alias of the subdomain (for example, cPanel creates
anotherexample.com as an alias of the
As with aliased domains and subdomains, the system automatically creates an equivalent
www. subdomain for each new addon domain (for example, the www.anotherexample.com and
www.anotherexample.example.com domains, which means that every addon domain creates a virtual host with four hostnames).
SSL-encrypted web content
In order to serve SSL-encrypted web content, cPanel creates a new virtual host that mirrors the non-SSL virtual host. This new virtual host adds the necessary configuration parameters for SSL. The same hostnames associate with the new virtual host and the old one, and both virtual hosts use the same document root.