Child pages
  • How Your Server Handles Domains and Virtual Hosts
Skip to end of metadata
Go to start of metadata

Overview

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:

  1. The user requests content from a remote host at a hostname (for example, the example.com domain).

    Note:

    In most cases, the term domain name can act as a synonym for hostname.

  2. The user’s computer resolves the hostname to an IP address (for example, example.com to 1.2.3.4).
  3. The user’s computer connects to the host with that IP address (1.2.3.4) 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, example.com and www.example.com are 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.

Note:

The rest of this document discusses virtual hosts as they pertain to web hosting. However, virtual hosts can also apply to other services, such as FTP or email.

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 example.com and www.example.com will retrieve the same content.

cPanel users can manage three different types of additional hostnames in the Domains group of features:

Hostname TypeDescription

Aliases

(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 example.com domain.

Aliases also configure the equivalent www. domain to associate with the same content (for example, www.anotherexample.com domain).

Note:

AutoSSL providers count aliased domains towards their domain and rate limits for virtual hosts.

Subdomains

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, subdomain.example.com and other.example.com are subdomains of the example.com domain).

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.

Addon Domains

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 anotherexample.example.com subdomain).

Then, cPanel creates the addon domain as an alias of the subdomain (for example, cPanel creates anotherexample.com as an alias of the anotherexample.example.com subdomain).

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.

Additional documentation