- Documentation
- Domains & Networking
- Redirect Root Domains
Redirect Root Domains
Guara Cloud custom domains are configured on subdomains, such as www.example.com, app.example.com, or api.example.com. If visitors should also reach your site from the root domain example.com, configure your DNS or CDN provider to redirect example.com to the subdomain you added in Guara Cloud.
The recommended setup is:
- Add
www.example.comas the custom domain in Guara Cloud. - Create the CNAME for
www.example.comexactly as shown in the dashboard. - Configure an HTTPS redirect from
example.comtohttps://www.example.com.
Why root domains are different
DNS uses CNAME records to make one hostname an alias of another hostname. Guara Cloud uses CNAME-based custom domain setup because your service target can change behind the scenes while your domain keeps working.
The DNS standards make root domains special. A root domain, also called an apex or naked domain, must already have records such as SOA and NS for the zone itself. The CNAME rule in RFC 1034 section 3.6.2 says that when a CNAME is present at a name, no other data should be present. RFC 1912 section 2.4 restates the operational rule that a CNAME cannot coexist with other data.
That is why many DNS providers do not allow a CNAME at example.com, even though they allow a CNAME at www.example.com.
What you should configure
Use the subdomain as the site Guara Cloud serves, and use the root domain only as a redirect.
-
Add the www domain in Guara Cloud
In the service Domains tab, add:
www.example.com -
Create the CNAME record
In your DNS provider, create the CNAME record shown by Guara Cloud:
Field Value Type CNAMEName www.example.comTarget The Guara Cloud target shown in the dashboard -
Redirect the root domain
In your DNS or CDN provider, configure a permanent redirect:
From To https://example.comhttps://www.example.comThe redirect should preserve the original path and query string. For example,
https://example.com/pricing?plan=proshould becomehttps://www.example.com/pricing?plan=pro. -
Make sure HTTPS works on the root domain
The redirect provider must be able to receive HTTPS traffic for
example.com. If HTTPS is not enabled there, browsers can fail before they ever reach the redirect.
If you use Cloudflare DNS
Cloudflare supports root-to-www redirects with Redirect Rules. Follow Cloudflare’s official guide: Redirect from root to WWW.
Use this shape:
- Hostname match:
example.com - Redirect target:
https://www.example.com - Status code:
301or308 - Preserve path and query string: enabled
Cloudflare must have a proxied DNS record for the root hostname so it can receive the request and apply the redirect rule. Use Cloudflare’s guide as the source of truth for the current dashboard fields.
If your registrar has URL forwarding
Some registrars offer “URL forwarding” or “domain forwarding”. It can work, but check these details before relying on it:
- It must support HTTPS for
https://example.com. - It should use a permanent redirect, usually
301or308. - It should preserve the path and query string.
- It must not use masked forwarding or frames.
- It should redirect to the exact subdomain you added in Guara Cloud, such as
https://www.example.com.
If the registrar only redirects http://example.com but not https://example.com, visitors who type or click the HTTPS URL can see a browser error before the redirect happens.
What not to do
- Do not point
example.comto the Guara Cloud CNAME target unless your DNS provider explicitly offers CNAME flattening, ALIAS, or ANAME behavior and you understand the provider-specific behavior. - Do not use masked forwarding. It keeps
example.comin the browser while embeddingwww.example.com, which breaks normal routing, cookies, analytics, and security expectations. - Do not add both
example.comandwww.example.comto Guara Cloud expecting Guara Cloud to redirect between them. Guara Cloud serves the exact hostname you configure; the root redirect belongs at your DNS or CDN provider.
How to test
After configuring the redirect, test both URLs:
curl -I https://example.com
curl -I https://www.example.com
The root domain should return a redirect status such as 301 or 308 with a Location header pointing at https://www.example.com. The www domain should return the response from your Guara Cloud service.
DNS and redirect changes can take time to propagate. Most changes are visible in minutes, but some providers and resolvers can cache the old behavior for longer.