A domain redirect sends visitors and crawlers from one host or URL to another using an HTTP status code so the right page loads every time.
Redirects sound simple until they aren’t. You might switch to HTTPS, drop www, move to a new brand name, or merge two sites. If you skip the redirect step, people hit dead ends, bookmarks fail, and search engines keep old addresses around longer than you’d like.
This walkthrough shows the clean way to redirect a domain. You’ll learn which redirect type to use, where to set it, and how to test it so you don’t ship a loop or a chain.
What A Domain Redirect Does
A redirect is a server response that tells a browser, “Don’t stay here. Go there.” The response includes an HTTP status code plus a target URL. Browsers follow it right away. Crawlers follow it too, then refresh their stored signals over time.
When people say “redirect a domain,” they usually mean one of these moves:
- Old domain to new domain: oldsite.com → newsite.com
- Non-www to www, or the other way: example.com → www.example.com
- HTTP to HTTPS: http://example.com → https://example.com
- Root to a path: example.com → example.com/app/
- One page to another page: /old → /new
Redirect Vs DNS Records
DNS points a name to an IP address. DNS does not send users to a new URL on its own. Redirection happens at the HTTP layer, meaning a web server, proxy, CDN, or app must answer the request and reply with a redirect code.
Redirect Vs Domain “Forwarding” At A Registrar
Many registrars offer forwarding. Under the hood, it is still an HTTP redirect, or a framed page that masks the real URL. If you want clean behavior for search engines and analytics, pick a true 301/302 redirect, not a frame.
Picking The Right Redirect Code
The status code tells browsers and crawlers how to treat the move.
301 Moved Permanently
Use a 301 when the old address is not coming back. This fits domain changes, canonical host changes, and HTTPS upgrades. Google’s notes on how it processes redirects are in Redirects and Google Search.
302 Found (Temporary)
Use a 302 when the move is short-lived, like a test or a short maintenance window. A 302 tells crawlers the old address may return, so they tend to keep it around longer.
307 And 308
307 (temporary) and 308 (permanent) keep the HTTP method the same on redirect. Many stacks still use 301/302 for simplicity. If your app relies on strict method behavior for POST requests, 307/308 can be a better fit.
How To Redirect A Domain Name With A Clean Plan
A good redirect setup starts before you touch settings. A few minutes of prep saves a lot of cleanup later.
Step 1: Choose One Canonical Host
Pick the one version of your site you want people to use, then push all other versions into it. Common choices are:
- https://example.com (no www)
- https://www.example.com (with www)
Use that same host in internal links, sitemaps, and your CMS settings.
Step 2: Map Old URLs To New URLs
If you are only redirecting the root domain, this is simple. If you are moving a full site, keep a list of old paths and their new targets. Match page-to-page rather than sending everything to the home page. That keeps user intent intact.
Step 3: Prevent Chains And Loops
A chain hops more than once: A → B → C. A loop bounces forever: A → B → A. Your goal is a single hop: A → B.
Where To Set Redirects
You can redirect at several layers. The best spot depends on your stack and what you control.
Registrar Forwarding
This is handy when you only own a domain and do not run hosting. Confirm the forwarding type is a real 301 or 302. If the tool uses a frame, use a host or CDN that can issue true redirects.
Web Server Rules (Apache Or Nginx)
This is the most direct route when you control hosting. The server answers requests for the old domain and issues the redirect before any app code runs.
CDN Or Proxy Rules
CDNs can redirect at the edge, close to the visitor. This helps when your origin is hard to change. Cloudflare’s dashboard can do URL forwarding with a chosen status code. Their steps are in URL forwarding with Page Rules.
Redirect Methods Compared
The table below shows common goals and a safe layer to implement each one.
| Goal | Best Place To Set It | Notes |
|---|---|---|
| Old domain to new domain | Server or CDN | Keep paths and query strings; aim for one hop. |
| HTTP to HTTPS | Server or CDN | Redirect all HTTP requests; fix mixed-content links too. |
| www to non-www (or reverse) | Server or CDN | Pick one canonical host and stick with it. |
| Single page moved | App or server | Use 301 for a permanent change; keep a redirect log. |
| Short test routing | CDN or app | Use 302 or 307; remove rules after the test ends. |
| Traffic split by country | CDN | Keep a clear default target for bots and unknown regions. |
| Retired content with a close replacement | App or server | Redirect to the nearest match, not a random category page. |
| Parked domain pointing to brand home | Registrar or CDN | A 301 fits when you do not plan to host content there. |
Server Rules That Stay Predictable
If you can edit server config, you can build redirects that are quick and easy to reason about. The aim is always the same: requests for the old host return a single 301 to the new host, with the path preserved.
Apache Patterns
Apache can redirect with mod_alias or mod_rewrite. For a whole-domain move, set the rule at the virtual host level so every request hits the redirect before WordPress or any other app runs. If you only need a few page moves, app-level redirects can be fine, but keep the list small.
Nginx Patterns
Nginx can redirect right at the start of the request. A server block that matches the old domain can return a 301 to the new domain while keeping the full request URI. After you deploy it, test both the root and a few deep pages to confirm the path stays intact.
TLS And Certificates On The Old Domain
If the old domain will accept HTTPS, it needs a valid certificate or browsers will show a warning before the redirect runs. Many CDNs handle this by provisioning TLS on the edge. If you run a direct origin, install a certificate for the old host too.
Testing Redirects So You Trust Them
Redirects can fail in quiet ways. Test with both a browser and a header check so you see the status code and the final destination.
Check The Status Code
- Use a command-line tool like curl -I to view response headers.
- In a browser, open DevTools → Network, click the first request, and read the status.
Confirm One-Hop Behavior
Type a deep URL on the old domain, not just the home page. You want the browser to land on the matching deep URL on the new domain in one hop. If you see multiple hops, fix the earliest redirect rule.
Make Sure Query Strings Survive
Marketing links, login callbacks, and filters often rely on query parameters. Test a URL like /page?utm_source=test. The target should keep the query string unless you have a clear reason to drop it.
Common Redirect Failures And Fixes
Everything Lands On The Home Page
This feels easy, but it breaks intent. If someone clicks a link to a product page and lands on the home page, they bounce. Map high-traffic pages one-to-one when possible.
Trailing Slash Mismatch
Some servers treat /page and /page/ as different URLs. Pick one style and redirect the other into it. This is a common source of chains.
Wildcard Rules Swallow Subdomains
A wildcard redirect can catch subdomains that should stay separate. List the subdomains you need, then write rules that only catch what you mean to catch.
Old Internal Links Never Get Updated
After a move, update internal links to point at the final URLs. Redirects are a safety net, not a long-term crutch. Clean internal links also cut down crawl waste.
Post-Move Checklist For A Calm Launch
| Check | What To Look For | Fix If It Fails |
|---|---|---|
| Root URL | Old domain lands on canonical home in one hop | Move the rule to the earliest layer |
| Deep URL | Paths carry over: /a/b stays /a/b | Add path-preserving rules, not a blanket to home |
| Status code | 301 for permanent moves, 302/307 for short moves | Swap the code in the redirect rule |
| Query string | Parameters remain on the target URL | Adjust rule variables to pass the full request |
| Canonical tags | Pages declare the new URLs, not the old domain | Update CMS settings and templates |
| Sitemaps | Sitemap URLs use the canonical host | Regenerate and resubmit after the move |
| Redirect chains | No multi-hop sequences in common entry pages | Collapse rules into one hop |
Keeping Redirects Easy To Maintain
Redirect rules can pile up. Keep them tidy with a few habits:
- Write down each new redirect with a reason in your change notes.
- Remove temporary redirects once the short task ends.
- Audit top landing pages monthly and confirm one-hop behavior.
- When you retire content, point it to the closest match, or return a clean 410 when no replacement exists.
Wrap-Up
A solid redirect setup is boring in a good way. Pick a canonical host, use the right status code, set rules at the earliest layer you control, then test deep URLs. Once the move is live, clean up internal links and watch for chains.
References & Sources
- Google Search Central.“Redirects and Google Search.”Explains how Google processes redirects and how it treats source and target URLs.
- Cloudflare Developers.“URL forwarding with Page Rules.”Shows how to set edge URL forwarding with 301 or 302 status codes.
