How to Make Your Domain Work With and Without www
Visitors type your domain both ways, so both must work. This guide covers choosing a preferred address, DNS records, redirects, SSL and testing.
9 min readUpdated Nov 19, 2026By XPASS Editorial Team

Most people never think about the difference between example.com and www.example.com. They type whichever comes to mind, or click a link written by someone else. For a site owner the difference matters a lot: if only one version works, a share of visitors will see an error, and if both work but show the same pages at two addresses, search engines and analytics tools may treat them as separate sites.
This guide explains how to make both versions of your domain work, how to choose a preferred one, and how to send visitors from the other to the preferred address. It covers DNS records, redirects and certificates, with a worked example and a troubleshooting table. When you finish, a visitor who types either address should land on the same page, over HTTPS, with no warnings.
Why both versions matter
The part before your domain, www, is a subdomain like any other. In DNS, example.com (often called the bare, root or apex domain) and www.example.com are two different names. Nothing forces them to point to the same place, and a registrar or host may set up only one of them. When that happens, one of the following is typical:
- Typing the address without
wwwfails with a "server not found" error, while thewwwversion works. - The reverse: the bare domain loads, but
wwwdoes not exist. - Both load, but with different content or different certificates.
Visitors do not know which version you set up. Old business cards, printed brochures and links on other sites will use whatever form people chose at the time. Supporting both avoids lost visitors.
There is a second reason. Search engines generally prefer that a page has one preferred address. Google's SEO Starter Guide discusses consolidating duplicate URLs, and a permanent redirect from one version to the other is one standard way to signal which one you prefer. Without it, links and statistics may split between two addresses.

Choosing a preferred version
You do not need to agonise over this. Both choices are valid, and neither is better for ranking by itself. Consider these practical points instead.
| Consideration | Bare domain (example.com) |
www (www.example.com) |
|---|---|---|
| Length | Shorter to type and print | Slightly longer |
| DNS flexibility | Needs an A or AAAA record at the root; a CNAME is not allowed there in standard DNS | Can be a CNAME to a hosting service, which is often easier |
| Hosting services | Some hosts want you to use www so they can change the server behind it |
Works with almost any host |
| Cookies | A cookie set for the bare domain can be shared with all subdomains | Cookies can be kept to the www host more easily |
If your hosting or content delivery service gives you a hostname rather than an IP address, www is often simpler because a CNAME is allowed there. If you want short addresses and your host gives you fixed IP addresses, the bare domain works well. Whatever you choose, write it down and use it everywhere: in links, email signatures, social profiles and your sitemap.
DNS records for both names
Both names need DNS records. Your domain's DNS zone is managed at the company that runs your name servers; if you are not sure where that is, look up the NS records. The article on checking DNS records with nslookup shows how.
There are two common patterns.
Pattern A: A record on the bare domain, CNAME for www.
| Name | Type | Value |
|---|---|---|
@ (the bare domain) |
A | the server's IPv4 address |
@ |
AAAA | the server's IPv6 address, if there is one |
www |
CNAME | example.com. |
The CNAME makes www an alias, so if the IP address changes, you only edit it in one place.
Pattern B: A records on both names.
| Name | Type | Value |
|---|---|---|
@ |
A | the server's IPv4 address |
www |
A | the same IPv4 address |
This is simple and works anywhere, but you must update both records when the address changes.
Pattern C: The host gives you a hostname instead of an IP address. Point www at that hostname with a CNAME. For the bare domain, you cannot use a CNAME in standard DNS, because the bare domain must also carry records such as NS and SOA. Options are an ALIAS or flattening feature if your DNS provider offers one, the IP addresses the host publishes for the bare domain, or a redirect service from the bare domain to www. Ask your host which they recommend.
In some panels, @ represents the bare domain. Others want the full domain name or leave the field empty. If you are unsure, check the preview before saving. A mistake such as typing example.com in a field that already appends the domain produces example.com.example.com.
Once saved, confirm the records with a lookup. The guide on checking DNS with dig for beginners shows how to ask for both names and read the answers.
Redirecting one version to the other
DNS only gets the visitor to a server. To show a single preferred address, the server (or your host's setting) should answer requests for the non-preferred name with a redirect to the preferred one. A permanent redirect is the usual choice. In HTTP, the standard permanent redirect codes are 301 and 308, defined in RFC 9110; they tell browsers and search engines that the move is lasting.
Where you set the redirect depends on your setup:
- Hosting control panel. Many panels have a "domain redirect" or "preferred domain" option. Choose the permanent type.
- Website platform. Many website builders and shop platforms let you mark one domain as the primary, and automatically redirect the other.
- Web server configuration. On your own server, you add a rule in the web server's configuration that redirects the non-preferred host name to the preferred one, preserving the path. For example, a request for
https://www.example.com/pricingshould go tohttps://example.com/pricing, not just to the home page. - Redirect at the DNS or registrar level. Some providers offer a forwarding feature. It works by pointing the name at the provider's own redirect server. Check that it supports HTTPS before relying on it.
Two details matter more than people expect:
- Preserve the path and query string. A redirect that sends every address to the home page frustrates visitors and loses the value of deep links.
- Avoid chains. Going from
http://www.example.comtohttps://www.example.comtohttps://example.comtakes three steps. Better to go directly to the final address in one step wherever you can.
HTTPS and certificates for both names
The padlock rules apply to both versions. A visitor who types https://www.example.com should get a valid certificate before the redirect even happens, because the browser checks the certificate first. If the certificate only lists the bare domain, the visitor sees a warning on the www address, and the redirect never gets a chance to run.
So make sure the certificate includes both names. Many hosting platforms issue certificates for both automatically after the DNS records are correct. If you manage your own certificates, request one that lists both example.com and www.example.com as names. A wildcard certificate such as *.example.com covers www but does not cover the bare domain itself, so a wildcard certificate normally lists both explicitly.
Once the site is stable on HTTPS, many owners also enable HSTS, a header that tells browsers to use HTTPS only. Do this carefully and only after you are sure that every name works over HTTPS, because browsers remember the instruction.
A worked example
Suppose the owner of mybrand.example hosts the site on a platform that publishes one IPv4 address, 203.0.113.40. She decides on the bare domain as her preferred address.
- In the DNS zone she adds an A record for
@pointing to203.0.113.40. - She adds a CNAME record for
wwwpointing tomybrand.example.. - In the platform, she adds both
mybrand.exampleandwww.mybrand.exampleas domains and sets the bare domain as primary. The platform issues a certificate for both and redirectswwwto the bare domain with a permanent redirect. - She tests four addresses:
http://mybrand.example,https://mybrand.example,http://www.mybrand.exampleandhttps://www.mybrand.example. All four end onhttps://mybrand.example. - She updates her email signature, social profiles and sitemap to use
https://mybrand.example.
The test of all four combinations is important. People often check only two and miss that one of the HTTP forms does not redirect.
Limits and what to watch for
- Caching hides your change. If you recently changed the records, resolvers may still return old answers until the TTL runs out. Lowering the TTL a day before a planned move shortens the wait. Allow time before concluding that something is broken.
- Redirects are cached by browsers. A permanent redirect can be remembered by a browser for a long time. If you test with a redirect you later change, clear the cache or use a private window.
- Do not redirect in both directions. If the platform redirects
wwwto the bare domain, and an old rule also redirects the bare domain towww, visitors get a loop and a "too many redirects" error. Keep one rule. - Email is separate. Email addresses at
you@example.comuse the domain's MX records, not the www name. Changing web records does not move your mail, but be careful not to delete mail records when you tidy the zone. - Third-party services may expect a name. Some tools ask you to verify ownership of a specific name. Verify the one you chose as preferred, and check whether the other is needed too.
- Not every host supports both. A few simple hosting services only answer for one of the two names. In that case use the provider's redirect feature or ask the provider how to add the second name.
- Subdomains are separate. A shop at
shop.example.comis not covered by anything you set forwww. See how to set up subdomains for a shop, blog and member area for that.
Troubleshooting
| Symptom | Likely cause | What to try |
|---|---|---|
www shows "server not found" |
No DNS record for www |
Add the CNAME or A record for www |
| Bare domain shows "server not found" | No record at the root | Add an A record for the root |
| Certificate warning on one version | Certificate lacks that name | Reissue or enable certificates for both names |
| "Too many redirects" | Two rules redirect in opposite directions | Remove one rule |
| Redirect lands on the home page only | Path not preserved | Update the rule to carry the path and query |
| Works for you but not for others | Caching or a recent change | Wait for the TTL and test from another network |
| The old site shows on one version only | The record points to the old server | Check both records at the DNS provider |
Work from DNS upward: check that both names resolve, then that the server answers for both, then the certificate, then the redirect. Fixing them in that order avoids chasing symptoms.
Summary
The bare domain and the www name are two separate names in DNS, so both need records and both need to work. Pick one as your preferred address, point both at the right place with A, AAAA or CNAME records, make sure the certificate lists both names, and send the other version to the preferred one with a permanent redirect that keeps the path. Test all four combinations of HTTP, HTTPS, with and without www, and avoid redirect loops and chains. If you are choosing or managing the domain behind your site, the domains page is a good place to continue.
Frequently asked questions
Should I use www or the bare domain?
Either works. The important part is to choose one as the preferred address and redirect the other to it, so that every page has a single consistent web address. Pick the one that is easier for your hosting setup to manage.
Do I need two DNS records to support both versions?
Yes. The bare domain and the www name are separate names in DNS, so each needs its own record. Commonly the bare domain has an A record and the www name is a CNAME that points to the bare domain, or both have A records.
Why can't I use a CNAME on the bare domain?
In standard DNS, a CNAME cannot share a name with other records, and the bare domain must carry required records such as NS and SOA. Some DNS providers offer an alias or flattening feature, but that is a provider feature rather than standard DNS.
Which type of redirect should I use between www and the bare domain?
A permanent redirect, usually HTTP status 301 or 308, is appropriate when you have chosen a preferred address. It tells browsers and search engines that the move is lasting.
Does my SSL certificate cover both versions?
Only if both names are listed in it. A certificate for the bare domain does not automatically cover the www name. Make sure the certificate includes both names, otherwise the redirect itself may show a security warning.
References
About the author

Bob Kanokphon Thongdee
- Founder of XPASS VPN
- Co-founder of eSIMonline.asia
- More than 7 years in online marketing
- Founder of Cojourney Visa and Cojourney Travel
Ready to register your domain?
Search a name, compare extensions and pay once for the years you choose.
.com registration from $18.81 for the first year
Search domainsKeep reading

Domain & DNS Guides
How to Check DNS with dig: A Beginner's Guide
dig shows exactly what DNS returns, including status codes, flags and TTLs. This beginner guide covers the commands you need and how to read every part of the output.
10 min read

Domain & DNS Guides
How to Set Up Subdomains for a Shop, Blog and Member Area
A subdomain lets one domain host a shop, a blog and a member area on separate services. This guide covers naming, DNS records, SSL and testing.
10 min read

Domain & DNS Guides
How to Check DNS Records with nslookup
nslookup is a built-in tool for asking DNS what it knows about a name. This guide shows the commands, how to read the answers and what to do when they look wrong.
9 min read