Apex Domain vs WWW: What's the Difference and Which Should You Use?
Every website owner faces this choice: should visitors reach your site at example.com or www.example.com? The answer has real technical consequences for performance, reliability, and hosting compatibility.
What Is an Apex Domain?
An apex domain (also called a root domain, naked domain, or bare domain) is the base version of your domain name without any subdomain prefix. If you registered example.com, then example.com itself is the apex domain.
In DNS terms, the apex domain is the zone apex — the top-level entry in your DNS zone file. It is the domain exactly as it was registered with your registrar, containing only the second-level label and the top-level domain (TLD).
Examples of apex domains:
example.commysite.orgcompany.io
What Is a WWW Subdomain?
The www subdomain is simply a subdomain prefixed with www. before the apex domain. When someone visits www.example.com, they are accessing the www subdomain of example.com.
Despite being a historical convention from the early web, the www prefix serves a genuine technical purpose today. As a proper subdomain, it can use a CNAME record in DNS, which gives it significant advantages in terms of infrastructure flexibility.
The www subdomain is not special from a DNS perspective — it functions exactly like any other subdomain such as api.example.com or blog.example.com. Its significance comes entirely from convention and the technical benefits that convention enables.
Technical Differences: The CNAME Problem
The most important technical difference between apex domains and www subdomains comes down to DNS record types and a fundamental constraint in the DNS specification.
According to RFC 1034, a CNAME record cannot coexist with any other record type at the same name. Since the apex domain must have SOA and NS records (these are required for the zone to function), you cannot place a CNAME record at the apex domain.
This matters because many modern hosting and CDN providers use CNAME records as their primary integration method. When a provider tells you to point your domain to your-app.provider.com, they are asking you to create a CNAME record — something that only works with subdomains like www.
DNS Record Comparison
# Apex domain — must use A/AAAA records
example.com. A 192.0.2.1
# WWW subdomain — can use a CNAME
www.example.com. CNAME your-app.provider.com.
Some DNS providers offer proprietary workarounds like ALIAS, ANAME, or CNAME flattening records that resolve this limitation at the DNS level. However, these are non-standard, not universally supported, and can interfere with features like geo-based load balancing.
Why WWW Is Better for Most Use Cases
For the majority of websites, using www as the canonical domain offers clear technical advantages:
CDN Compatibility
Content delivery networks like Cloudflare, Fastly, and AWS CloudFront integrate most cleanly through CNAME records. Using www lets you point your domain to any CDN endpoint without workarounds, giving you the ability to switch providers quickly if needed.
Cookie Isolation
Cookies set on the apex domain (example.com) are automatically sent to every subdomain (www.example.com, api.example.com, cdn.example.com). By serving your site from www.example.com, you can set cookies only on the www subdomain, keeping your API and static asset subdomains free of unnecessary cookie overhead. This improves performance and reduces bandwidth usage.
Load Balancing Flexibility
CNAME records let your DNS provider or CDN handle IP address resolution dynamically. This means the provider can route traffic to the nearest or healthiest server automatically. With A records at the apex, you are locked to specific IP addresses, making failover and geographic load balancing harder to manage.
DNS Migration Simplicity
If you ever need to change hosting providers, a CNAME-based setup on www means you update a single record. With an apex domain using A records, you may need to update multiple records and wait for propagation across every DNS resolver that has cached your old IP addresses.
When Using the Apex Domain Is Fine
Not every website needs the flexibility that www provides. Using the apex domain as your canonical domain can be perfectly acceptable in certain scenarios:
- Simple static sites hosted on a single server with a fixed IP address
- DNS providers with ALIAS/ANAME support that effectively flatten CNAME records at the apex
- Small personal projects where CDN failover and cookie isolation are not concerns
- Brand preference when a shorter URL is important for marketing and you have the DNS infrastructure to support it
Even in these cases, it is still good practice to ensure both example.com and www.example.com resolve and one redirects to the other, so visitors always reach your site regardless of which version they type.
Hosting Services That Require (or Strongly Prefer) WWW
Several popular hosting and deployment platforms either require or strongly recommend using a www subdomain for custom domains:
GitHub Pages
Requires a CNAME for custom domains. Apex domains need A records pointing to GitHub's IPs, but www with CNAME is the recommended setup.
Netlify
Recommends www as the primary domain. Supports apex via Netlify DNS, but CNAME on www is the standard integration path.
Vercel
Supports both apex and www, but uses CNAME records for www subdomains and A records for apex. WWW provides more flexible routing.
Heroku
Requires CNAME records for custom domains, making www the only straightforward option. Apex domains need a DNS provider with ALIAS support.
If you use any of these platforms (or similar PaaS/Jamstack providers), configuring www as your primary domain and redirecting the apex to it is the path of least friction.
How to Redirect Your Apex Domain to WWW
Once you decide to use www as your canonical domain, you need to ensure that visitors who type the bare domain still reach your site. The best approach is a 301 permanent redirect from the apex to www. This tells browsers and search engines that the www version is the definitive address.
With ApexToWWW, setting up this redirect takes just two DNS records and no account or configuration:
Add these records at your DNS provider:
@ A 65.109.111.88
@ AAAA 2a01:4f9:5a:3e92::2
That is it. When a visitor requests example.com, the DNS resolves to ApexToWWW's servers, which respond with a 301 redirect to www.example.com. SSL certificates are provisioned automatically, the original path and query string are preserved, and both IPv4 and IPv6 are supported.
There are no accounts to create, no configuration dashboards, and no ongoing fees. The service handles millions of redirects reliably, so you can focus on building your site on the www subdomain.
Conclusion: Use WWW and Redirect the Apex
For most websites, especially those using CDNs, PaaS hosting, or any service that relies on CNAME records, www is the better choice as your canonical domain. It gives you more flexibility with DNS, cleaner cookie scoping, easier provider migrations, and compatibility with the widest range of hosting services.
The best practice is straightforward: set www.example.com as your primary domain, then redirect example.com to it with a 301 redirect. Your visitors will never notice the difference, but your infrastructure will be more resilient and easier to manage.
Ready to set up your apex-to-www redirect? Get started with ApexToWWW in under a minute — just add two DNS records and you are done.