How to redirect a domain
To redirect a domain, you need a web server that answers every request for the old domain with a 301 pointing at the new one. DNS alone can't do it, because DNS only turns names into addresses. Your registrar's URL redirect feature, Cloudflare or your own hosting can provide that server.
Redirect checkerUpdated 3 min read
Why no DNS record redirects
A redirect is an HTTP response: a 3xx status code with a Location header holding the new address, as MDN's guide to redirections describes. DNS answers a different question, which is where to find a name. An A record gives an IP address. A CNAME, as RFC 1034 defines it, makes one name an alias of another name. Neither can hold a URL or a status code.
So when a registrar offers a "URL redirect record", it's a shortcut. Namecheap, for example, explains that its URL Redirect Record adds a hidden A record pointing your domain at Namecheap's forwarding server, and that server sends the redirect.
Your options
At your registrar. Many registrars offer domain forwarding. It's the simplest choice when the old domain has no website of its own. See how to set up a URL redirect on Namecheap for a worked example: you choose the destination and Permanent (301), then remove any A, CNAME or ALIAS records on the same host.
With Cloudflare. If the domain's DNS is on Cloudflare, a Redirect Rule sends every request to the new domain and can keep the path. Cloudflare's docs note the hostname must be proxied through Cloudflare for the rule to run. See how to redirect a URL in Cloudflare.
On your own server. If the old domain still points at your hosting, a single line in Apache's .htaccess or an IIS setting does it. See redirecting with .htaccess or redirecting in IIS.
Keep the path
A good domain redirect sends olddomain.com/menu to newdomain.com/menu, not just to the new home page. Otherwise every link people saved, and every result search engines indexed, lands on the front page. Apache's Redirect directive and Cloudflare's wildcard rules both carry the path across. Registrar forwarding varies, so test a deep link as well as the home page.
Cover every version of the old domain
People and old links use all of these, and each needs to reach the new domain:
- http://olddomain.com
- https://olddomain.com
- http://www.olddomain.com
- https://www.olddomain.com
The https versions need a valid certificate on the old domain, or the browser shows a warning before any redirect can happen. Namecheap's documentation makes the same point for its own forwarding.
301 or 302?
The HTTP standard, RFC 9110, says a 301 means the resource has a new permanent address that future links ought to use, while a 302 is temporary. Google follows the same split: for a permanent redirect it shows the new address in results, for a temporary one it keeps the old. When you've moved to a new domain for good, use 301 or 308. 307 and 308 behave like 302 and 301 but keep the request method, which only matters for forms.
Check the redirect
Paste each version of the old domain into the checker, plus a deep link such as olddomain.com/contact. Each should reach the matching page on the new domain in as few hops as possible, every one a 301 or 308.
Redirect checker
Open the full toolIf you see http → https → www → new domain, that's three hops where one would do. Point the first redirect straight at the final address; redirect chains explains why it matters.
How long it takes
Two clocks run. DNS changes take time to reach everyone, depending on the records' time to live. Namecheap says its forwarding usually works within 30 minutes. After that, browsers that saw an old 301 may remember it, so test in a private window.
Sources
- RFC 1034: Domain Names, Concepts and Facilities, section 3.6.2 Aliases and canonical names, checked 2026-11
- How to set up a URL redirect for a domain (Namecheap Knowledgebase), checked 2026-11
- Redirects (Cloudflare Rules docs), checked 2026-11
- Redirections in HTTP (MDN), checked 2026-11
- Redirects and Google Search (Google Search Central), checked 2026-11
- RFC 9110: HTTP Semantics, section 15.4 Redirection 3xx, checked 2026-11
Questions
Which DNS record redirects a domain?
None of the standard ones. DNS turns names into addresses; a redirect is an HTTP response from a web server. Registrars' "URL redirect records" point your domain at their own web server, which sends the redirect.
Can a DNS entry point to a URL?
No. A CNAME points one name at another name, such as www.example.com at example.net, never at a URL with a path. To send people to a URL, a web server has to answer with a redirect.
Should I use 301 or 302 for a domain redirect?
301 (or 308) when you've moved for good, so search engines show the new domain. 302 or 307 only if the old domain will come back into use.
What does a 307 or 308 redirect mean?
307 is a temporary redirect and 308 a permanent one, like 302 and 301, except the browser must keep the request method. That matters for forms that post data, not for ordinary links.