Subdomain
What is a subdomain?
A subdomain is a DNS-based hostname placed before a parent domain, such as app.example.com or docs.example.com. It sends browser and software requests to a specific application, server, or service under the same registered domain. In app.example.com, “app” is the subdomain, “example” is the registered domain, and “.com” is the top-level domain. A subdomain is a hostname, not a folder such as example.com/app, and does not automatically mean a separate website.
How a subdomain works in DNS
DNS translates a hostname into a destination. A subdomain needs a DNS record and a destination configured to serve that hostname.
- A user or application requests a hostname such as api.example.com.
- DNS finds an A or AAAA record for an IP address, or follows a CNAME record to another hostname.
- The request reaches a web server, hosting platform, load balancer, or edge network.
- The service routes the hostname to the correct application or deployment.
- An HTTPS certificate must cover the hostname for a trusted secure connection.
Subdomain vs. subdirectory
Both organize web content, but create different technical boundaries.
| Area | Subdomain | Subdirectory |
|---|---|---|
| Example | app.example.com | example.com/app |
| Routing | Separate DNS and hostname routing | Usually one host and application route |
| Cookies and CORS | Can require explicit cross-origin planning | Usually shares one origin |
| Best fit | Independent apps, APIs, or environments | Closely related site sections |
| Search visibility | Needs deliberate linking and measurement | Often simpler to manage as one site structure |
Common software uses for subdomains
Subdomains clarify a service’s role and allow independent routing.
- app.example.com for a signed-in web application.
- api.example.com for an application programming interface.
- docs.example.com or status.example.com for documentation and service status.
- staging.example.com and preview.example.com for pre-release testing.
- tenant.example.com for customer-specific application instances.
- eu.example.com for regional routing or localized experiences.
Benefits of using subdomains
A subdomain can reduce coupling between services without another registered domain.
- Independent deployments and infrastructure for each hostname.
- Clearer ownership for teams maintaining different services.
- Safer testing when staging traffic is isolated from production.
- Flexible routing to a CDN, API gateway, or different hosting provider.
Practical limits and security considerations
A subdomain is an organizational and routing tool, not a security boundary by itself.
- DNS changes can take time to propagate, so plan ownership and rollback procedures.
- Certificates must include each hostname, or use a correctly managed wildcard certificate.
- Host-only cookies stay on one hostname, while cookies set for.example.com may be sent to multiple subdomains.
- Different subdomains are different web origins, so CORS, redirects, and authentication need explicit configuration.
- Protect staging and preview hosts from indexing, public access, and production credentials.
- Use consistent names for production, testing, and service endpoints.
Using subdomains when deploying with Emergent
When deploying a full-stack product built with an AI web app builder, plan a production hostname such as app.example.com and separate URLs for staging or previews. Emergent helps teams build and ship applications, while a clear hostname plan keeps deployment destinations understandable. Explore related web terms in the Emergent glossary. Deploy distinct app experiences with Emergent.
on Emergent today

