What is a Subdomain?
A subdomain is a domain that exists as part of a larger parent domain, created by adding a prefix to the main domain name. In "blog.example.com," "blog" is the subdomain of "example.com." Subdomains allow website owners to organize content, host separate applications, or create distinct sections without registering additional domain names. They're created through DNS configuration at no extra registration cost.
Subdomain Structure
blog.example.com
│ │ │
│ │ └── TLD (Top-Level Domain)
│ └── Root domain (Second-Level Domain)
└── Subdomain (Third-Level Domain)
Multiple levels possible:
dev.api.example.com
│ │ │
│ │ └── Root domain
│ └── First subdomain
└── Second subdomain (fourth level)
Common Subdomain Uses
| Subdomain | Typical Purpose |
|---|---|
| www | Main website (traditional) |
| blog | Blog or news section |
| shop/store | E-commerce platform |
| app | Web application |
| api | API endpoints |
| Webmail access | |
| dev/staging | Development environments |
| support/help | Customer support portal |
| cdn | Content delivery |
| m/mobile | Mobile-optimized site |
Creating Subdomains
DNS Configuration
Add records for the subdomain in your DNS zone:
; A record pointing to IP
blog.example.com. A 192.0.2.10
; CNAME pointing to another domain
shop.example.com. CNAME mystore.shopify.com.
; Multiple subdomains
api.example.com. A 192.0.2.20
dev.example.com. A 192.0.2.30
Wildcard Subdomains
Match all undefined subdomains:
*.example.com. A 192.0.2.100
Subdomain vs Subdirectory
| Aspect | Subdomain | Subdirectory |
|---|---|---|
| URL | blog.example.com | example.com/blog |
| DNS required | Yes | No |
| Separate hosting | Easy | Complex |
| SEO authority | Separate | Shared |
| SSL certificate | May need wildcard | Covered by main cert |
| Analytics | Separate property | Same property |
When to Use Subdomains
- Different platforms/technologies
- Separate applications
- Multi-tenant systems
- Geographic targeting
- Development environments
When to Use Subdirectories
- Blog or content sections
- SEO consolidation desired
- Simple site organization
- Same technology stack
Subdomain SEO Considerations
Search Engine Treatment
- Google treats subdomains as separate sites
- Link equity doesn't automatically transfer
- Each subdomain builds authority independently
- May require separate Search Console verification
Best Practices
1. Use subdomains for truly separate entities
2. Use subdirectories to consolidate SEO
3. Implement proper canonicalization
4. Set up separate analytics tracking
5. Create XML sitemaps for each subdomain
Security Considerations
SSL Certificates
| Certificate Type | Coverage |
|---|---|
| Single domain | example.com only |
| Wildcard | *.example.com (one level) |
| Multi-domain SAN | Specific listed domains |
Cookie Scope
Set-Cookie: session=abc; Domain=.example.com
# Accessible to all subdomains
Set-Cookie: session=abc; Domain=blog.example.com
# Only accessible to blog subdomain
Subdomains provide flexible organization for websites and applications, allowing distinct sections to operate independently while remaining part of the parent domain's namespace.