· 8 min read

Apex Domain Redirect: 5 Methods Compared

TL;DR

There are five common ways to redirect an apex domain to www: a free DNS redirect service (ApexToWWW), Cloudflare Redirect Rules, ALIAS/ANAME records, registrar-provided domain forwarding, or a self-hosted nginx/Apache redirect. For most sites, a DNS redirect service wins on setup time, SSL handling, and DNS-provider compatibility — the others make sense in specific situations covered below.

If you already know you need to redirect an apex domain but aren't sure which method fits your setup, this breaks down the trade-offs of each.

Why You Need to Redirect the Apex at All

Per RFC 1034, DNS doesn't allow a CNAME record at the apex (root) of a zone. Most modern hosting platforms — Vercel, Netlify, GitHub Pages, Cloudflare Pages, Heroku — hand you a hostname, not an IP address, which means they expect a CNAME. That works fine on www but not on the apex. See What Is an Apex Domain? for the full technical breakdown.

The standard fix is to serve your site from www (which can take a CNAME) and redirect the apex to it with an HTTP 301. There are several ways to implement that redirect. Here's how they stack up.

Comparison at a Glance

Method Cost Setup time Any DNS provider Server to maintain Auto SSL
DNS redirect service (ApexToWWW) Free ~2 min Yes None Yes
Cloudflare Redirect Rules Free ~5 min Cloudflare only None Yes
ALIAS / ANAME record Free ~5 min Provider-dependent None Depends on target
Registrar domain forwarding Free–varies ~2 min Yes None Often no
Self-hosted nginx/Apache Server cost 30–60 min Yes Yes Manual (Certbot)

1. DNS Redirect Service (ApexToWWW)

A DNS-based redirect service points your apex domain's A and AAAA records at servers that do nothing but respond with a 301 to your www URL. ApexToWWW is one implementation of this pattern: add an A record (65.21.184.101) and an AAAA record (2a01:4f9:c012:a304::1) to your apex, and every request to yourdomain.com gets redirected to https://www.yourdomain.com, path and query string intact, with SSL provisioned automatically via Let's Encrypt.

Best for: sites hosted on any CNAME-based platform (Vercel, Netlify, GitHub Pages, Heroku, and similar), regardless of which company manages your DNS. No account, no server, no ongoing maintenance.

2. Cloudflare Redirect Rules (or Page Rules)

If Cloudflare is already your authoritative DNS provider, you can create a Redirect Rule matching your apex hostname and 301 it to www, entirely inside the Cloudflare dashboard. This is free on every Cloudflare plan and avoids adding a third-party redirect service to the chain.

Best for: teams already running Cloudflare DNS who don't mind Cloudflare being the single point of control for both DNS and the redirect rule. See our Cloudflare Pages apex redirect guide for the exact rule configuration.

3. ALIAS / ANAME Records

Some DNS providers (Route 53, DNSimple, and others) offer ALIAS or ANAME record types that resolve like a CNAME but are legal at the apex. Instead of redirecting, this serves your site directly on the apex — no www redirect hop at all.

Best for: teams who want the apex domain itself as their canonical URL (no www), and whose DNS provider supports ALIAS/ANAME. The trade-off: you're locked into providers that support the feature, and it only works if your hosting platform's target hostname resolves cleanly through it.

4. Registrar Domain Forwarding

Most domain registrars (GoDaddy, Namecheap, and others) include a basic "domain forwarding" feature in their dashboard. Quality varies a lot: some registrars implement a real HTTP 301 with SSL; others use frame-based forwarding (the browser URL never changes, which confuses users and hurts SEO) or a meta-refresh redirect with no HTTPS support at all.

Best for: quick, low-stakes redirects where you've confirmed your specific registrar returns a proper 301 with SSL. Always test with curl -I before relying on it — see the step-by-step redirect guide for the exact command.

5. Self-Hosted nginx or Apache

You can run your own server (a small VPS is enough) with an nginx or Apache config that 301-redirects the apex to www. This gives you full control — custom redirect logic, header manipulation, whatever you need.

Best for: teams with existing infrastructure and ops capacity who want the redirect logic to live inside their own stack. The cost is real: a server to patch and monitor, and your own TLS certificate lifecycle (Certbot/Let's Encrypt, renewed on a cron job) to manage indefinitely for a task that's otherwise a two-record DNS change.

Which Method Should You Use?

  • Default choice for most people: a DNS redirect service like ApexToWWW — free, fastest setup, works regardless of DNS provider or hosting platform.
  • Already on Cloudflare DNS: Cloudflare Redirect Rules keep everything in one dashboard.
  • Want apex as canonical, DNS provider supports it: ALIAS/ANAME avoids the redirect hop entirely.
  • Already running your own infrastructure: self-hosted nginx/Apache if the ops overhead is a non-issue for your team.
  • Avoid: registrar forwarding you haven't verified returns a real 301 with SSL — test it first.

Frequently Asked Questions

What is the best way to redirect an apex domain to www?

For most sites, a free DNS-based redirect service like ApexToWWW is the best option: it's standards-compliant, works with any DNS provider, needs no server or account, and returns a proper 301 with automatic SSL. Cloudflare Redirect Rules are a strong alternative if Cloudflare is already your DNS provider.

Is domain forwarding from my registrar good enough?

It depends on the registrar. Some offer proper 301 redirects with free SSL, which is fine. Others use frame-based forwarding or a meta refresh with no HTTPS support, which hurts SEO and looks broken to visitors. Check whether your registrar's forwarding returns an HTTP 301 status code and provisions an SSL certificate before relying on it.

Do I need to run my own server to redirect an apex domain?

No. Self-hosted nginx or Apache redirects work but require you to run, patch, and monitor a server plus manage your own TLS certificates. DNS-based redirect services like ApexToWWW and Cloudflare Redirect Rules achieve the identical result — a 301 to www — without any server to maintain.

Does the redirect method affect SEO?

Only if it's implemented incorrectly. A proper HTTP 301 (permanent redirect) preserves search ranking signals and is what Google recommends. Frame-based forwarding, meta refresh redirects, and 302 (temporary) redirects can all cause SEO problems — duplicate content, lost ranking signals, or search engines refusing to consolidate the two URLs. Always verify your chosen method returns a real 301.

Try the fastest option

Add two DNS records, and ApexToWWW handles the rest — automatic SSL, IPv6, and HTTP/3 included. No account required.

Get Started Free

Published on

← Back to all articles