What Is a Subdomain? Complete Guide to Creating and Managing Subdomains
Whether you're running a growing business website, launching a separate blog, or deploying a customer support portal, subdomains give you the flexibility to organize your online presence without registering additional domain names. In this comprehensive guide, we'll cover exactly what subdomains are, how they work, when to use them, and how to create and configure them step by step — including web server setup for both Apache and Nginx.
What Is a Subdomain?
A subdomain is a prefix added to your primary domain name that creates a distinct, independently manageable section of your website. Technically, it forms a separate hostname within the same DNS namespace as your root domain.
Example:
| Component | Value |
|---|---|
| Primary Domain | example.com |
| Subdomain | blog.example.com |
| Another Subdomain | store.example.com |
In the example above, blog and store are subdomains of example.com. Each subdomain can point to a completely different server, directory, or application — all while sharing the same root domain.
How Do Subdomains Work?
Subdomains function through the Domain Name System (DNS). When a user types blog.example.com into their browser, the DNS resolver looks up the DNS records for that specific hostname. If an A record or CNAME record exists for blog.example.com, the browser is directed to the corresponding IP address or server.
This means subdomains are:
- Independently configurable — each can point to a different server or IP address
- Infinitely scalable — you can create as many subdomains as your DNS provider allows
- Free to create — no additional domain registration is required
If you're managing your own infrastructure on a VPS Hosting plan, you have full control over DNS records, web server configuration, and subdomain routing.
Common Use Cases for Subdomains
Subdomains are used across virtually every type of web project. Here are the most common real-world applications:
blog.example.com— A separate blog or content hubstore.example.com— An eCommerce storefronthelp.example.com— A knowledge base or customer support portalapp.example.com— A web application or SaaS dashboardapi.example.com— A REST API endpointmail.example.com— An email server (used in MX and mail routing records)staging.example.com— A development or staging environmentm.example.com— A mobile-optimized version of your site
Each of these can run on entirely separate infrastructure. For high-traffic applications, you might host store.example.com on a Dedicated Server while keeping your main marketing site on a lighter Shared Web Hosting plan.
Subdomains vs. Subdirectories: Which Should You Use?
Before creating a subdomain, it's worth understanding when a subdirectory might be a better choice.
| Feature | Subdomain (`blog.example.com`) | Subdirectory (`example.com/blog`) |
|---|---|---|
| SEO Treatment | Treated as a separate entity by Google | Inherits root domain authority |
| Server Flexibility | Can point to a different server | Must reside on the same server |
| Setup Complexity | Requires DNS + server config | Simpler, no DNS changes needed |
| Use Case | Separate apps, services, environments | Content sections of the same site |
General rule: Use subdomains when you need technical separation (different server, platform, or application). Use subdirectories when you want consolidated SEO authority for content that belongs to the same site.
How to Create a Subdomain: Step-by-Step
Step 1: Log In to Your DNS Management Panel
Every domain registrar and hosting provider offers a DNS management interface. Log in to your account and navigate to the DNS Zone Editor, DNS Management, or Advanced DNS section for your domain.
> If you registered your domain through AlexHost, you can manage DNS records directly from your client dashboard. Need a new domain? Check out Domain Registration to get started.
Step 2: Add a New DNS Record
To create a subdomain, you need to add either an A record or a CNAME record in your DNS zone.
#### Option A: A Record (Points to an IP Address)
Use an A record when you want the subdomain to point directly to a server's IP address.
Host: blog
Type: A
Value: 123.456.789.0 ← Your server's IPv4 address
TTL: 3600This creates the subdomain blog.example.com and routes traffic to the specified IP.
#### Option B: CNAME Record (Points to Another Domain)
Use a CNAME record when you want the subdomain to point to another hostname — for example, a CDN, a third-party service, or another domain you control.
Host: shop
Type: CNAME
Value: stores.platform.com
TTL: 3600> Important: You cannot use a CNAME record for the root domain (@ / example.com). CNAMEs are only valid for subdomains.
#### DNS Propagation
After saving your DNS records, allow up to 24–48 hours for full global propagation, though changes often take effect within minutes to a few hours.
Step 3: Configure Your Web Server
If you're running your own web server — such as on a VPS or dedicated server — you must configure it to recognize and handle requests for the new subdomain. Without this step, visitors will receive a connection error even after DNS propagates correctly.
#### Configuring Nginx for a Subdomain
Create a new server block configuration file for your subdomain:
sudo nano /etc/nginx/sites-available/blog.example.comAdd the following configuration:
server {
listen 80;
listen [::]:80;
server_name blog.example.com;
root /var/www/blog;
index index.html index.php;
access_log /var/log/nginx/blog.access.log;
error_log /var/log/nginx/blog.error.log;
location / {
try_files $uri $uri/ =404;
}
}Enable the configuration and reload Nginx:
sudo ln -s /etc/nginx/sites-available/blog.example.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx#### Configuring Apache for a Subdomain
Create a new virtual host configuration file:
sudo nano /etc/apache2/sites-available/blog.example.com.confAdd the following virtual host block:
<VirtualHost *:80>
ServerName blog.example.com
DocumentRoot /var/www/blog
ErrorLog ${APACHE_LOG_DIR}/blog_error.log
CustomLog ${APACHE_LOG_DIR}/blog_access.log combined
<Directory /var/www/blog>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>Enable the site and reload Apache:
sudo a2ensite blog.example.com.conf
sudo apache2ctl configtest
sudo systemctl reload apache2Step 4: Create the Web Root Directory
Make sure the document root directory you specified actually exists and contains your website files:
sudo mkdir -p /var/www/blog
sudo chown -R www-data:www-data /var/www/blog
echo "<h1>Blog Subdomain is Live</h1>" | sudo tee /var/www/blog/index.htmlStep 5: Secure the Subdomain with SSL/TLS
Every subdomain should be served over HTTPS. Leaving a subdomain on plain HTTP exposes users to security risks and can hurt your search rankings.
#### Option A: Free SSL with Let's Encrypt (Certbot)
sudo apt install certbot python3-certbot-nginx # or python3-certbot-apache
sudo certbot --nginx -d blog.example.comCertbot will automatically obtain a certificate and update your Nginx (or Apache) configuration to serve HTTPS traffic.
#### Option B: Wildcard SSL Certificate
If you plan to create multiple subdomains, a wildcard SSL certificate (*.example.com) covers all of them under a single certificate. This is the most efficient option for projects with many subdomains.
> AlexHost offers a range of SSL Certificates including wildcard options to secure all your subdomains with a single installation.
Step 6: Test Your Subdomain
Once DNS has propagated and your web server is configured, verify everything is working:
- Open your browser and navigate to
http://blog.example.com(orhttps://if SSL is configured) - Use an online DNS propagation checker (e.g., whatsmydns.net) to verify the A/CNAME record is resolving globally
- Check your web server error logs if the subdomain isn't loading:
- Nginx:
sudo tail -f /var/log/nginx/blog.error.log - Apache:
sudo tail -f /var/log/apache2/blog_error.log
Managing Multiple Subdomains
For websites with several subdomains, organization becomes critical. Here are some best practices:
- Use a wildcard DNS record (
*.example.com → your server IP) to route all subdomains to your server, then handle routing at the web server level - Document your DNS zone — keep a record of every subdomain, its purpose, and where it points
- Set appropriate TTLs — use lower TTL values (e.g., 300 seconds) when you anticipate making changes, and higher values (e.g., 86400) for stable records
- Monitor subdomain uptime independently — each subdomain is effectively a separate site and should be monitored accordingly
- Clean up unused subdomains — abandoned subdomains can become security vulnerabilities (subdomain takeover attacks)
Subdomains and Email Hosting
Subdomains also play a role in email infrastructure. Records like mail.example.com are commonly used as the hostname for mail servers, referenced in MX records and SMTP configurations.
If you're setting up professional email for your domain or a subdomain, Email Hosting provides a fully managed solution with spam filtering, webmail access, and reliable deliverability — without the complexity of self-hosting a mail server.
Frequently Asked Questions About Subdomains
How many subdomains can I create?
Technically, DNS allows an unlimited number of subdomains. In practice, your domain registrar or DNS provider may impose limits, but most allow hundreds or thousands.
Do subdomains affect SEO?
Google treats subdomains as separate entities from the root domain. This means a subdomain generally does not inherit the domain authority of example.com. For content-focused sites, subdirectories are often preferred for SEO consolidation. However, for applications, tools, or services that are genuinely distinct, subdomains are perfectly appropriate.
Can I use a subdomain without a web server?
Yes — you can create DNS records for a subdomain that point to third-party services (e.g., a hosted form, a CDN endpoint, or a SaaS platform) without configuring your own web server.
Are subdomains free?
Yes. Creating subdomains requires no additional domain registration fees. You only need an existing registered domain and access to its DNS settings.
Can I point a subdomain to a different hosting provider?
Absolutely. Because subdomains are resolved via DNS, you can point app.example.com to a cloud provider, blog.example.com to a CMS platform, and store.example.com to your own server — all independently.
Conclusion
Subdomains are one of the most powerful and flexible tools available for organizing your web infrastructure. They allow you to run separate applications, services, and content sections under a single root domain — each with its own server configuration, SSL certificate, and independent management.
To recap the key steps:
- Add a DNS A or CNAME record for the subdomain in your DNS management panel
- Configure your web server (Nginx or Apache) with a new server block or virtual host
- Create the document root and deploy your content
- Secure the subdomain with an SSL certificate
- Test and monitor to confirm everything is working correctly
Whether you're hosting a single subdomain or managing a complex multi-subdomain architecture, having the right infrastructure underneath makes all the difference. Explore AlexHost's VPS Hosting plans for full root access and complete control over your subdomain configuration — or browse our VPS Control Panels if you prefer a GUI-based management experience.
