X
X
X
X

What Is a Subdomain? When to Use One and How to Set It Up

HomepageArticlesDomain NamesWhat Is a Subdomain? When to Use On...

In short: What is a subdomain? A subdomain is a label added to the left of a domain you own. If you own example.com, then blog.example.com, shop.example.com and support.example.com are all subdomains. They let you publish a blog, a shop, a test environment or a separate application at its own address without buying a new domain, and setting one up takes a DNS record, a site folder on the server and an SSL certificate.

What is a subdomain and where does it sit in a domain?

Internet addresses live in a tree-shaped naming system called DNS. At the top of the tree are extensions such as .com, .net or .com.tr; below them is the domain you registered; and below that are the subdomains you create (RFC 1034, DNS concepts). Each dot in an address separates one level, and you read it from right to left: in blog.example.com, "com" is the extension, "example" is your domain and "blog" is the subdomain.

If you have not yet read what a domain is and why it matters, our what is a domain name guide is a good starting point. The key property of a subdomain is that you do not have to buy anything new: if you own the domain, you also control the names below it.

A familiar example is "www". Technically, www.example.com is a subdomain; many sites send both the www and the non-www address to the same site.

When should you use a subdomain?

A subdomain is useful when you want to publish a service that is clearly separate from the main site at its own address. Common uses:

  • A blog or knowledge base: running the blog in a separate application while the main site uses different software (blog.example.com).
  • An online shop: keeping the e-commerce software apart from the corporate site (shop.example.com).
  • A test or staging environment: a copy for trying changes before they reach the live site (test.example.com). It is good practice to protect such an environment with a password and keep it out of search engines.
  • Separate applications: a customer portal, a help desk or a web app (portal.example.com).
  • Mail and service addresses: names such as mail.example.com usually point to a server or a service.

Subdomain or subfolder?

You could publish the same content at example.com/blog instead of blog.example.com. Which one fits better depends on your technical setup. If the blog runs on the same software and server as the main site, a subfolder is usually simpler to manage. If different software, a different server or a different team is involved, a subdomain makes setup and maintenance easier.

When deciding, ask yourself: is the content a natural part of the main site? Will it share the same design and menu? Does it need separate software? Who will manage it? The answers usually make the right choice clear.

Setting up a subdomain: blog A and shop CNAME DNS records, a separate site folder, a *.example.com wildcard certificate and its one-level scope

How to set up a subdomain step by step

  1. Choose the name. Short, clear, single-word names (blog, shop, support) are easy to remember and to type.
  2. Add the DNS record. Use an A record to point the subdomain at a server's IP address, or a CNAME record to point it at another host name. Our DNS records (A, MX, CNAME, TXT) guide explains the difference.
  3. Prepare the site folder on the server. A separate folder (the document root) holds the subdomain's files. How you do this depends on your hosting plan; if you are not sure, open a support ticket and ask.
  4. Add the SSL certificate. The main domain's certificate does not automatically cover a subdomain. You need either a separate certificate for the subdomain or a wildcard certificate in the form *.example.com.
  5. Wait for propagation and test. A new DNS record can take time to become visible everywhere; our DNS propagation article explains why. Then open the address in a browser and check the certificate and the pages.

What does a wildcard certificate cover?

A wildcard certificate in the form *.example.com accepts exactly one level in place of the asterisk: blog.example.com and shop.example.com are covered, but a name two levels down such as a.blog.example.com is not (RFC 6125). A wildcard certificate also does not usually include the bare domain (example.com) itself, which is why certificates often list both names together.

If you want a wildcard certificate from Let's Encrypt, validation must use the DNS-01 method, which means adding a TXT record to the domain; HTTP-based validation cannot be used for wildcards (Let's Encrypt challenge types). If you only use a few subdomains, a separate certificate for each one is also a practical option.

Subdomains and search engines

Search engines see subdomains as separate addresses, so give each subdomain's page titles, internal links and sitemap their own attention. When you add a Domain property in Google Search Console, that property covers all subdomains and protocols together (Google Search Console help). For the verification steps, see our Search Console domain verification guide.

Security: clean up unused subdomains

If you pointed a subdomain at an external service with a CNAME and later shut that service down, the DNS record may be left behind. Such a dangling record can let someone else claim that name on the same service and publish content on your subdomain; this is called a subdomain takeover (MDN: Subdomain takeovers). The fix is simple: when you retire a service, delete the DNS record that points to it first, and review your DNS records regularly.

Frequently Asked Questions

Do I need to buy a new domain for a subdomain?

No. If you own the domain, you create the subdomains below it yourself with DNS records; you do not need to buy another domain.

Is www a subdomain?

Technically, yes. www.example.com is a name below the example.com domain. Many sites send both addresses to the same site.

Does my main domain's SSL certificate protect a subdomain too?

Not automatically. A subdomain needs its own certificate or a wildcard certificate in the form *.example.com, and a wildcard covers only one level.

How long after adding a subdomain will it work?

The DNS record has to propagate, which depends on the record's TTL and on resolver caches. Once the record is visible and the site folder and certificate are ready, the address opens.


Powered by WISECP
Top