Creating DNS Records for Subdomains
A subdomain is a prefix added to your main domain, creating a separate address like blog.yourdomain.com or shop.yourdomain.com. Subdomains are managed through DNS records and can point to the same server as your main site or to entirely different servers.
Common Uses for Subdomains
www.yourdomain.com– The most common subdomain, usually pointing to the same site as the root domain.blog.yourdomain.com– A blog hosted separately from the main site.shop.yourdomain.com– An online store on a different platform (e.g., Shopify).mail.yourdomain.com– Webmail access.staging.yourdomain.com– A staging or development environment.api.yourdomain.com– An API endpoint.
Setting Up a Subdomain with an A Record
Use this when you know the IP address of the destination server:
- In your DNS management panel, add a new A record.
- Set the Name to the subdomain prefix (e.g.,
blog). - Set the Value to the server's IP address.
- Save the record.
Setting Up a Subdomain with a CNAME Record
Use this when pointing to a third-party service that provides a hostname:
- Add a new CNAME record.
- Set the Name to the subdomain prefix (e.g.,
shop). - Set the Value to the target hostname (e.g.,
shops.myshopify.com.). - Save the record.
Wildcard Subdomains
A wildcard DNS record (*.yourdomain.com) matches any subdomain that does not have its own specific record. This is useful for:
- Multi-tenant applications where each customer gets a unique subdomain.
- Catching misspelled subdomains and directing them to a default page.
To create a wildcard record, use * as the name in an A or CNAME record.
Hosting Configuration
After creating the DNS record, you also need to configure the subdomain in your hosting control panel (DirectAdmin) so the web server knows which directory to serve content from for that subdomain.