Subdomains explained
A subdomain is a name in front of your domain, such as shop.example.com or blog.example.com. It lets you run separate sites or services under one domain without buying another. This guide explains what subdomains are used for, how to create one with DNS records, and how they work with SSL certificates.
What a subdomain is
Domain names are read from right to left. In shop.example.com, .com is the extension, example is the name you registered, and shop is the subdomain. You can create as many subdomains as you need at no cost from the registry, because they live entirely in your own DNS records.
Each subdomain can point somewhere different. example.com can run on your web hosting while shop.example.com runs on an online store service and help.example.com points to a support tool.
Common uses
| Subdomain | Typical use |
|---|---|
www | The website itself. Strictly speaking, www is a subdomain, and most sites make it show the same site as the domain. |
shop or store | An online store, often on a separate platform |
blog | A blog run separately from the main site |
mail | A name for an email server or webmail login |
staging or dev | A private test copy of the website |
Create a subdomain
You create a subdomain by adding a DNS record for it at the provider that runs your nameservers. Which record you need depends on what the other service gives you.
- An IP address, such as
203.0.113.25: add an A record (or an AAAA record for an IPv6 address). - A hostname, such as
stores.example.net: add a CNAME record, which makes the subdomain an alias of that name.
- Find out which nameservers your domain uses, as described in Nameservers explained, and open the DNS editor at that provider.
- Add a new record. In the name field, type only the subdomain part, such as
shop. Most editors add.example.comfor you. - Choose A or CNAME and enter the IP address or hostname exactly as the service gave it.
- Save, then check the result after a few minutes.
The finished records look like this:
blog.example.com. 3600 IN A 203.0.113.25
shop.example.com. 3600 IN CNAME stores.example.net.
Check them from a terminal:
dig +short blog.example.com
dig +short shop.example.com
On Windows, use nslookup shop.example.com.
A subdomain with a CNAME record cannot have any other records. If the service asks for a TXT record to verify the subdomain, it usually gives it a different name, such as _verify.shop, so the two do not clash.
Point a subdomain to another service
When a service such as a store platform or a help desk asks you to "connect your domain", it usually wants a subdomain with a CNAME record pointing to its own hostname. The service also needs to know the subdomain on its side, so add shop.example.com in its settings as well. Until both sides match, visitors often see an error page from the service.
If your web hosting runs the subdomain instead, you usually also add it in your hosting control panel or account so the server knows which folder to serve. The exact place depends on your host.
Subdomain or subfolder?
A subfolder is a path on the same site, such as example.com/blog. Both approaches work. Choose based on how the content is run:
Subdomain (blog.example.com) | Subfolder (example.com/blog) | |
|---|---|---|
| Where it runs | Can be a completely separate service or server | Part of the same website and hosting |
| Setup | A DNS record, plus setup on the other service | Created inside the website itself |
| Best when | The content runs on a different platform | The content belongs to the same site and app |
Search engines can index both. If the content is part of your main site and runs on the same software, a subfolder is usually simpler to manage.
SSL certificates for subdomains
Every name a visitor uses needs to be covered by an SSL certificate, or the browser shows a warning. A certificate for example.com does not automatically cover shop.example.com.
- A certificate that lists each name covers exactly the names on it, such as
example.com,www.example.comandblog.example.com. Add new subdomains to it, or issue a separate certificate for each. - A wildcard certificate for
*.example.comcovers any subdomain one level deep, such asshop.example.comandblog.example.com. It does not coverexample.comitself, so that name is usually listed too, and it does not cover deeper names such aseu.shop.example.com.
When a subdomain points to another service, that service normally issues the certificate for it once your DNS record is in place. SSL certificates explained covers certificate types in more detail.
DNS management is included with no extra fees for every domain registered with DomainPilot, so you can add subdomain records whenever you need them.
Related guides
- DNS records explained
- Nameservers explained
- SSL certificates explained
- Connect a domain to a website