Skip to content
Web Hosting

How to Add a Subdomain and Point It to a Folder in cPanel

In this article8 sections

A subdomain gives a part of your business its own address, such as shop.example.com or staging.example.com, and it can point at its own folder on the same cPanel account. It is the simplest way to run a second site, a test copy or a customer portal without buying another domain. The setup has three parts: the subdomain itself, the folder it serves, and the DNS record that sends visitors to the server. This guide covers each one, and the checks that show the subdomain works before you link to it.

SiteHarbour’s cPanel hosting plans include subdomains on every account, within the website limit of your plan. Check the limit on your plan before you add one, because each subdomain counts as a website in some plans.

Before you start

  • The domain is on the same account, and its DNS is served by the server, or you can add records at the registrar.
  • A name for the subdomain that describes its purpose, such as shop, blog or staging.
  • A folder for its files. A new folder keeps the subdomain separate from the main site, so a file in one does not affect the other.

Step 1: Create the subdomain in cPanel

In cPanel, open Subdomains under Domains. Enter the name in the subdomain field and choose the domain from the list. The document root field fills in with a folder name under public_html. Change it to a clear name if the default is not what you want, such as public_html/shop. Select Create.

Expected: the subdomain appears in the list with its folder. cPanel creates the folder if it does not exist. If you already have files in that folder, they become the subdomain’s site, so check the folder before you create the subdomain.

Step 2: Check the DNS record

When the domain’s DNS is served by the server, cPanel adds the record for the subdomain automatically. If the DNS is at the registrar, add an A record for the subdomain that points to the server’s IP address. Check the record from a terminal:

dig +short shop.example.com

Expected: the server’s IP address. If the answer is empty, the record has not been published yet, and DNS changes can take time to spread. Wait and check again before you assume the setup is wrong.

Step 3: Add the site files

Upload the files for the subdomain into its folder with File Manager or SFTP. For a test page, create an index.html file with a single line of text. Keep the files in the subdomain’s folder only. A file placed in public_html is served by the main site, not the subdomain.

For WordPress on a subdomain, install WordPress in the subdomain’s folder, using Softaculous and the subdomain as the domain. The install steps are in how to install WordPress with Softaculous on cPanel.

Step 4: Turn on HTTPS for the subdomain

Open SSL/TLS Status in cPanel and check that the subdomain is included in the certificate. If AutoSSL has not issued a certificate for it yet, run it from the same page, or wait for the next automatic run. A subdomain without its own certificate shows a warning in the browser, even when the main site is secure.

Test the address in a browser and check the padlock. Then check that the plain HTTP address redirects to HTTPS, using the same method as in how to fix mixed content in WordPress after SSL.

Load the subdomain’s home page and one inner page. Check that the page loads the right files and not the main site’s. Then search for the subdomain in a search engine only after it is ready. A half-built subdomain in search results gives visitors a broken first impression.

Common mistakes

  • Using a folder that already holds the main site. Both sites then serve the same files, and changes affect both.
  • Forgetting the certificate. A subdomain without its own certificate shows a security warning.
  • Creating too many subdomains. Each one is a site to maintain, back up and update. Remove the ones you no longer use.
  • Leaving a test subdomain public. Add a password to it, or block search engines, as covered in how to set up a WordPress staging site.

Frequently asked questions

Is a subdomain the same as a separate domain?

No. It is part of your domain and shares the account’s resources and certificates, so it is cheaper, but a problem on the account can affect all of them.

Can a subdomain have its own PHP version?

Yes, in cPanel’s PHP settings, select the subdomain and choose its version separately from the main site.

How do I remove a subdomain?

Delete it from the Subdomains list. cPanel removes the DNS record and the subdomain’s entry. Delete its folder yourself when you are sure you no longer need the files, after a backup.

Does a subdomain help search ranking?

It can be treated as a separate site by search engines, so it needs its own content and links to matter. For most sites, a folder on the main domain is the better choice for ranking.

A subdomain is a folder with its own address. Create it in cPanel, check the DNS record, put the files in its own folder, and confirm it has a certificate before you link to it. For the folder layout of a whole account, read how to keep your cPanel account and sites secure.

Share this guide