What Is a Subdomain? How Subdomains Work

What subdomains are, how they work in DNS, common uses, how to create them, and the SEO and technical implications of using subdomains vs subdirectories.

A subdomain is a domain that is part of a larger domain. In blog.example.com, the subdomain is blog, and it belongs to the parent domain example.com. Subdomains let you organize different sections of your web presence under a single domain, point them to different servers, and manage them independently.

You already use subdomains every day. When you visit www.example.com, www is a subdomain. When you access mail.google.com or docs.google.com, those are subdomains of google.com. This guide explains how subdomains work at the DNS level, how to create them, and when they are the right choice. For a broader understanding of DNS, see DNS Resolution: How It Works.

How Subdomains Work in DNS

In DNS, every domain name is a hierarchy read from right to left. The domain blog.example.com has three levels:

  • .com is the top-level domain (TLD)
  • example is the second-level domain
  • blog is the third-level domain (the subdomain)

At the DNS level, a subdomain is just another record in the parent domain's zone file. Creating a subdomain means adding a DNS record (A, AAAA, CNAME, or another type) for the subdomain name within the parent domain's DNS zone.

; In the example.com zone file
blog.example.com.     300    IN    A        93.184.216.34
shop.example.com.     300    IN    CNAME    shops.myshopify.com.
api.example.com.      300    IN    A        93.184.216.50

Each subdomain can point to a different IP address, a different server, or even a different hosting provider. The parent domain's nameservers handle queries for all subdomains unless a subdomain has been delegated to separate nameservers using NS records.

Creating a Subdomain

Creating a subdomain involves adding a DNS record at your DNS provider. No registration or additional purchase is required. You can create as many subdomains as your DNS provider allows (most have no practical limit).

Step by Step

  1. Log into your DNS provider's management panel.
  2. Navigate to the DNS records for your domain.
  3. Add a new record:
    • Type: A (to point to an IP address) or CNAME (to point to another hostname).
    • Name/Host: The subdomain name (e.g., blog, shop, staging). Most providers automatically append your domain.
    • Value: The IP address or target hostname.
    • TTL: Start with 300 seconds during setup. Increase after confirming it works.
  4. Save the record.
  5. Wait for DNS propagation (typically a few minutes, up to 48 hours in some cases).

Pointing a Subdomain to a Different Server

One of the most common reasons to use subdomains is to host different parts of your site on different servers:

example.com         A    93.184.216.34       (main website on your server)
blog.example.com    CNAME  yoursite.wordpress.com  (blog on WordPress.com)
shop.example.com    CNAME  shops.myshopify.com     (store on Shopify)
docs.example.com    CNAME  yoursite.gitbook.io     (docs on GitBook)

Each service handles its own content. Users see your domain in the URL, and each service operates independently.

Delegating a Subdomain

For more complex setups, you can delegate an entire subdomain to different nameservers. This gives separate teams or services full control over the subdomain's DNS:

staging.example.com    NS    ns1.otherservice.com.
staging.example.com    NS    ns2.otherservice.com.

With delegation, the parent domain's nameservers do not manage any records under staging.example.com. All queries for that subdomain go directly to the delegated nameservers. See DNS NS Record Explained for details on delegation.

Common Uses for Subdomains

www

The most ubiquitous subdomain is www. It was originally used to distinguish the web server from other services (mail, ftp, etc.) running on the same domain. Today, most sites either redirect www to the bare domain or vice versa.

Staging and Development Environments

staging.example.com
dev.example.com
preview.example.com

Subdomains are widely used for non-production environments. They keep development and staging traffic separate from production while sharing the same domain's SSL certificates (if you use a wildcard certificate).

API Endpoints

api.example.com
graphql.example.com

Hosting your API on a subdomain lets you point it to different infrastructure, scale it independently, and apply different caching or security rules.

Regional Sites

us.example.com
eu.example.com
jp.example.com

International organizations sometimes use subdomains for regional content, each potentially hosted on servers in the corresponding geographic region.

SaaS Multi-Tenant Applications

customer1.example.com
customer2.example.com

SaaS platforms often give each customer a subdomain. This provides branded URLs while keeping all customers under the same parent domain.

Content Platforms

blog.example.com
docs.example.com
support.example.com
status.example.com

Different content types often live on different platforms. A blog might be on WordPress, documentation on GitBook or ReadTheDocs, support on Zendesk, and status pages on a status page provider.

Subdomains vs Subdirectories for SEO

This is one of the most debated topics in SEO. Should your blog be at blog.example.com (subdomain) or example.com/blog (subdirectory)?

The Subdirectory Argument

Google has stated that it treats subdomains as part of the main site in most cases. However, many SEO practitioners report better ranking performance with subdirectories. The reasoning:

  • Link equity consolidation. Links to example.com/blog/post benefit the entire example.com domain directly. Links to blog.example.com/post may or may not consolidate authority with the parent domain as effectively.
  • Domain authority sharing. Content on a subdirectory inherits the domain's existing authority. A new subdomain starts with less established authority in practice.
  • Simpler internal linking. Content on the same domain can link to other content without crossing domain boundaries.

The Subdomain Argument

  • Technical independence. Subdomains can run on different platforms, servers, and tech stacks without affecting the main site.
  • Separation of concerns. A staging or development subdomain should not share cookies or sessions with production.
  • Performance isolation. Traffic spikes on a subdomain do not affect the main site if they are on different infrastructure.

Practical Guidance

For content that benefits from your main domain's authority (blog posts, resource pages, guides), use subdirectories when feasible. For services that need technical independence (APIs, apps, staging environments, third-party hosted tools), use subdomains.

Google's John Mueller has said that Google can generally figure out the relationship between subdomains and the parent domain, but subdirectories make it easier. If your primary goal is SEO, subdirectories have a slight edge.

Choose based on architecture, not just SEO

The subdomain vs subdirectory decision should account for your technical requirements, team structure, and hosting architecture, not just SEO. A blog on a completely different tech stack is much easier to manage as a subdomain. A blog on the same CMS as your main site is easier to manage as a subdirectory.

Subdomain SSL Certificates

Each subdomain needs a valid SSL certificate to serve HTTPS traffic. You have several options:

Wildcard Certificates

A wildcard certificate (e.g., *.example.com) covers all subdomains one level deep. It covers blog.example.com, shop.example.com, and api.example.com. It does not cover multi-level subdomains like staging.api.example.com or the bare domain example.com (you need a separate certificate or a SAN entry for the bare domain).

SAN Certificates

A Subject Alternative Name (SAN) certificate lists multiple specific domain names. You can include example.com, www.example.com, blog.example.com, and shop.example.com on a single certificate. See SAN Certificates: Multi-Domain SSL Explained for details.

Individual Certificates

Each subdomain can have its own certificate. This is common when subdomains are hosted on different servers or by different providers. Let's Encrypt makes this free and automated.

Third-Party Hosted Subdomains

When a subdomain is pointed via CNAME to a third-party service (Shopify, WordPress.com, Heroku), the third party typically handles the SSL certificate. You configure the CNAME, and the service provisions a certificate for your subdomain.

Multi-Level Subdomains

DNS supports subdomains of subdomains, creating multi-level hierarchies:

api.staging.example.com
v2.api.example.com
us-east.cdn.example.com

Each level is separated by a dot. There is no practical limit on the number of levels, though the total domain name cannot exceed 253 characters.

Multi-level subdomains are common in cloud infrastructure (AWS uses multi-level subdomains extensively) and in organizations with complex internal DNS.

Wildcard DNS Records

A wildcard DNS record matches any subdomain that does not have its own explicit record:

*.example.com.    300    IN    A    93.184.216.34

With this record, anything.example.com, random.example.com, and test.example.com all resolve to 93.184.216.34, unless a specific record exists for that subdomain.

Wildcards are useful for SaaS platforms that provide custom subdomains and for catch-all configurations. Be cautious with wildcard records: they can mask mistyped subdomain names that you might want to fail rather than resolve. See Wildcard DNS Record for details.

Monitoring Subdomains

Subdomains increase your attack surface. Each subdomain is a potential entry point, and forgotten subdomains (those pointing to decommissioned services) can be vulnerable to subdomain takeover attacks.

Monitor your subdomains for:

  • DNS record changes. Unauthorized changes to subdomain records can redirect traffic.
  • Dangling CNAMEs. A CNAME pointing to a service you no longer use can be claimed by an attacker.
  • Certificate expiry. Each subdomain with its own certificate needs monitoring.

References

  1. RFC 1034, "Domain Names - Concepts and Facilities," November 1987. https://datatracker.ietf.org/doc/html/rfc1034
  2. Google Search Central, "Google crawling documentation," https://developers.google.com/search/docs/crawling-indexing
  3. Cloudflare Learning Center, "What is a subdomain?" https://www.cloudflare.com/learning/dns/glossary/dns-subdomain/

Monitor all your subdomains from one dashboard

DNS Monitor tracks DNS records across your domain and all its subdomains. Get alerted when records change, catch dangling CNAMEs, and keep your DNS infrastructure under control.

Try DNS Monitor