How to Create a Subdomain: A Complete Guide

Subdomains are one of the most practical tools in web development — useful for organizing large sites, separating environments, or launching entirely new sections without buying a new domain. But the setup process varies depending on your hosting provider, DNS configuration, and what you're actually trying to build.

Here's a clear breakdown of how subdomains work and what's involved in creating one.

What Is a Subdomain?

A subdomain is a prefix added to your root domain, separated by a dot. If your root domain is example.com, then blog.example.com, shop.example.com, and dev.example.com are all subdomains.

Technically, subdomains are part of the DNS (Domain Name System) hierarchy. Your root domain sits one level below the top-level domain (.com, .org, .net), and subdomains sit one level below that. You can create as many as your hosting plan allows — most providers support dozens to hundreds.

Common use cases include:

  • Staging environmentsstaging.example.com for testing before going live
  • Regional sitesuk.example.com or fr.example.com
  • Separate apps or servicesapp.example.com, api.example.com
  • Content sectionsblog.example.com, support.example.com

The Two Core Steps: DNS Record + Server Configuration

Creating a subdomain always involves at least two actions, even if your hosting panel automates both.

1. Add a DNS Record

Every subdomain needs a DNS record that tells the internet where to route traffic for it. The most common record types used are:

Record TypeWhen to Use
A RecordPoints subdomain to an IPv4 address
AAAA RecordPoints subdomain to an IPv6 address
CNAME RecordPoints subdomain to another domain name (e.g., a CDN or third-party service)

You add these records through whoever manages your DNS zone — this is usually your domain registrar (like Namecheap or GoDaddy) or your hosting provider, depending on where your nameservers are pointed.

For example, to create blog.example.com pointing to an IP address, you'd add an A record with:

  • Host/Name:blog
  • Value: your server's IP address
  • TTL: typically 3600 seconds (1 hour) or as recommended

DNS changes can take anywhere from a few minutes to 48 hours to fully propagate, though most updates resolve within an hour.

2. Configure the Server

Adding a DNS record alone doesn't make a subdomain serve content — your web server also needs to know what to do when traffic arrives for that subdomain.

How this works depends on your setup:

  • cPanel/shared hosting: Most panels have a dedicated "Subdomains" section. You enter the subdomain name, choose a root domain, and assign a document root (the folder where files are served from). The panel handles both DNS and server configuration automatically.
  • Apache: You create a new Virtual Host block in your configuration file pointing to the subdomain and its document root.
  • Nginx: You create a new server block with a server_name directive matching the subdomain.
  • Cloud platforms (Vercel, Netlify, etc.): You typically add a custom domain in the dashboard and point a CNAME or A record from your DNS provider to their servers.

🔧 If you're on managed hosting with a control panel, the process is usually a few clicks. If you're managing your own VPS or dedicated server, you'll be editing configuration files directly.

SSL Certificates and Subdomains

A critical detail many people overlook: SSL certificates don't automatically extend to subdomains.

If your root domain has an SSL certificate, blog.example.com won't be secured by it unless you're using a wildcard certificate (*.example.com) or you issue a separate certificate for each subdomain.

With tools like Let's Encrypt (via Certbot), you can issue free SSL certificates for individual subdomains or wildcard certificates if your DNS provider supports the required DNS-01 challenge. Many hosting panels automate this through AutoSSL or similar tools.

Variables That Affect How You Create a Subdomain 🌐

The actual process looks different depending on several factors:

  • Hosting environment — Shared hosting with cPanel is mostly GUI-based; a bare VPS requires manual server configuration
  • DNS provider vs. hosting provider — If they're separate, you'll be working in two different dashboards
  • CMS or framework — WordPress multisite, for example, has its own subdomain configuration layer on top of server setup
  • SSL approach — Wildcard vs. per-subdomain certificates require different setup processes
  • Third-party services — Pointing a subdomain to an external platform (like a help desk, e-commerce tool, or email service) typically uses CNAME records and may involve domain verification steps on the third-party side

What Can Go Wrong

The most common issues when setting up subdomains:

  • DNS not propagated yet — The subdomain resolves for some users but not others; this is temporary
  • Mixed content warnings — Subdomain is live but SSL isn't configured, so browsers flag it as insecure
  • 404 or 500 errors — DNS is set correctly but the server isn't configured to handle the subdomain
  • Redirect loops — Common when CMS rewrite rules conflict with server-level configuration

Each of these points back to a specific layer: DNS, server config, SSL, or application-level settings.


How straightforward your subdomain setup will be depends heavily on whether you're working inside a managed hosting panel, a custom server environment, or a third-party deployment platform — and whether your DNS is handled in the same place or separately. The technical steps are consistent, but the interfaces and tools vary enough that the right process for your situation may look quite different from someone else's.