What is a subdomain? Examples, uses and how to set one up
Kofi Agyem, Founder and CEO, CloudzyroPublished · 5 min read
On this page
A subdomain is a name in front of your domain, like blog.example.com. What they're for, subdomain vs subfolder, the DNS records to add and how to check.
1. The short answer
A subdomain is an extra name in front of your domain, like `blog.example.com` or `shop.example.com`. It's part of the domain you already own, it's free to create, and it can point to a completely different website or server from your main site. You make one by adding a DNS record for it.
Domains are read from right to left: in blog.example.com, .com is the ending, example is the name you registered, and blog is the subdomain. See What is a domain name? for the full picture.
2. Examples you've seen
www.example.com: the most common subdomain of all.blog.example.com,shop.example.com,help.example.com: sections run on separate tools.app.example.comordashboard.example.com: the signed-in part of a product.mail.example.com: often the mail server.uk.example.com,de.example.com: regional versions.staging.example.com: a test copy before changes go live.
Subdomains can be nested, like api.eu.example.com. Every site on Cloudzyro Sites & Apps also gets a free subdomain of ours, like mybakery.cloudzyro.app, which keeps working after you add your own domain.
3. What subdomains are good for
- Running different software side by side. Your main site on one platform, your shop on a store builder, your docs somewhere else.
- Separating an app from the marketing site, so each can be deployed on its own.
- Testing. Put a staging copy at
staging.example.com. - Isolation. Browsers keep many things, like local storage, separate per host name, which helps keep areas with other people's content apart from your main site.
4. Subdomain vs subfolder
The alternative is a subfolder (also called a subdirectory): example.com/blog instead of blog.example.com.
- Subfolder: one site, one host, one set of DNS records. Simpler to run, and everything sits under one domain in search.
- Subdomain: its own records, so it can live anywhere. Better when the content runs on different software or is managed by a different team.
Google has said its systems handle both. Choose based on how the content is built and run. If everything comes from one app, a subfolder is usually simpler.
5. How to create a subdomain
Add a DNS record for the subdomain wherever your domain's DNS is managed (find out with dig +short NS example.com). The record type depends on what your host asks for:
- CNAME to a name your host gives you. Most modern hosts prefer this. See A record vs CNAME.
- A record to an IP address your host gives you.
For example, to put a site hosted on Cloudzyro Sites & Apps at blog.example.com:
- In the console, open the site's Domains tab and add
blog.example.com. - At your DNS provider, add the record below. Some providers want the full name,
blog.example.com, instead ofblog. - If your DNS is at Cloudflare, set the record to DNS only (the gray cloud).
- Wait a few minutes. The domain goes from Waiting for DNS to Getting the certificate, then Live, and the HTTPS certificate is set up for you.
Type Name Target
CNAME blog domains.cloudzyro.appOn cPanel hosting, such as Cloudzyro Web Hosting, you create the subdomain in cPanel under Domains, which also creates its folder, and its DNS record when the domain uses the hosting's nameservers.
More detail in the docs: Connect a custom domain.
6. Subdomains and HTTPS certificates
Every name visitors use needs to be covered by an HTTPS certificate, or browsers show a warning. A certificate for www.example.com doesn't cover blog.example.com. There are two ways to cover subdomains:
- One certificate per name. Hosts that issue certificates automatically, like Let's Encrypt-based hosts, usually do this for each name you add. Nothing for you to do.
- A wildcard certificate for
*.example.com, which covers every name one level down (blog.example.com, but notapi.eu.example.com).
On Cloudzyro, the certificate for each domain or subdomain you add is set up and renewed for you. If your domain has CAA records, they must allow letsencrypt.org, pki.goog and ssl.com.
7. A worked example
Leo runs a design studio. His main site is on cPanel hosting at www.leostudio.com, and he's built a client portal with an AI tool that he wants at portal.leostudio.com on Cloudzyro Sites & Apps.
- He deploys the portal. It goes live at a free address,
leo-portal.cloudzyro.app, so he can check it first. - On the site's Domains tab he adds
portal.leostudio.com. - He finds his DNS is at his registrar (
dig +short NS leostudio.com) and adds a CNAME forportalpointing todomains.cloudzyro.app. - A few minutes later the domain shows Live with a certificate.
His main site, his email and their records are untouched: only the one new name points somewhere new. That's the main appeal of subdomains: each one is independent.
8. Wildcard subdomains
A wildcard record, *.example.com, answers for every subdomain that doesn't have its own record. Platforms use them to give every customer an address. For most sites you don't need one, and it can hide typos by making every made-up name resolve.
9. Common mistakes
- A CNAME next to another record. A name with a CNAME can't have any other record, so remove any old A record on that subdomain first.
- The domain added twice. Entering
blog.example.comas the name at a provider that adds the domain itself givesblog.example.com.example.com. - Editing records where the nameservers don't point. Check the NS records first.
- Cookies shared too widely. A cookie set for the whole of
example.comis sent to every subdomain. Keep login cookies on the exact host that needs them. - Forgotten subdomains. A subdomain left pointing at a service you've canceled can sometimes be claimed by someone else on that service. Delete records you no longer use.
10. How to check a subdomain
# What does the subdomain point to?
dig +short blog.example.com
# Just the CNAME, if it has one
dig +short CNAME blog.example.com
# Windows
nslookup blog.example.comIf it returns nothing, the record isn't there yet or is at the wrong provider. If it returns an old value, wait for the TTL to pass (see What is DNS?). For a Cloudzyro site, the Domains tab says what it found, and the domain troubleshooting guide explains each message.