New format
Site redirects: 301, 302, and when to use each
A redirect is a 3xx server response that sends the browser or crawler to another URL. That’s how you glue mirrors, move sections, and fix old links.
Below: the codes that matter for SEO, everyday 301 jobs, how redirects differ from rel=canonical, and mistakes like chains or landing on the wrong page. After every change, recheck status codes in `.htaccess` or nginx.
What a redirect is
The client requests URL A; the server answers “look at B” with a 3xx code. The browser opens B; crawlers factor the redirect type into crawl and URL consolidation.
Why sites use them:
- consolidating http/https and www/non-www
- moving a section or the whole domain
- changing extensions or slugs
- cleaning extra slashes and junk URLs
301, 302, 307 — which to pick
301 means “moved permanently” — the main tool for consolidations and migrations. 302 Found and 307 Temporary Redirect are temporary; ranking weight more often stays with the source URL.
Other 3xx codes (300, 303, 304, 305…) rarely need hand-tuning in day-to-day SEO — cache, proxies, content negotiation. Don’t confuse them with 301.
Quick overview
| Code | Meaning | Typical case |
|---|---|---|
| 301 | Permanent | New slug, new domain, https |
| 302 / 307 | Temporary | Promo, A/B, maintenance |
| canonical | Not a redirect | Duplicates that should stay open |
When to use 301
Consolidate mirrors to one canonical host (HTTPS plus your chosen www variant). Otherwise search sees different URLs with the same content.
For a site or section move: map old→new and avoid long chains. A CMS migration that keeps URL meaning should also 301 from the old addresses.
Checklist after setup:
- homepage and 5–10 key URLs resolve in one hop
- no redirects into a 404
- sitemap updated to final URLs
- in Search Console / webmaster tools, mark the move or primary mirror after a domain change
How to set up and verify
On Apache, rules often live in `.htaccess` (RewriteRule). On nginx, use `return 301` / `rewrite`. Generators help beginners — always verify the result yourself.
After edits, walk the homepage, key service pages, old bookmarks, and external links. Check the status code in DevTools or with `curl -I`.
What to avoid:
- chains of multiple redirects
- 301s between pages with different intent (size/color variants in a catalog)
- redirects to an irrelevant or empty page
- temporary 302s where the move is already permanent
Redirect vs canonical
`rel="canonical"` marks the preferred URL among available copies. A user can still open the non-canonical address.
If the old URL shouldn’t exist anymore — 301. If duplicates are needed for UX (filters, params) but only one should index — prefer canonical plus careful indexing controls.
Bottom line
Redirects tidy URLs: permanent moves → 301, temporary → 302/307, no chains, no swapped page intent. Align HTTPS/www mirrors and check responses after every deploy.
FAQ
Which redirect matters most for SEO?
301 Moved Permanently — a permanent move. Search engines gradually pass signals to the new URL.
When should I use 302 or 307?
When the move is temporary (promo, test, maintenance). For a permanent domain or slug change — 301.
Redirect or canonical?
Canonical says “prefer this URL,” but the old one may stay open. A 301 moves the user and signals a move more strongly. Dead URLs after a migration → 301.
Are redirect chains bad?
Yes: A→B→C→D costs speed and sometimes signal. Aim for one hop: A→C.
Do I still need Host in robots.txt?
Mirrors and the primary host are set in webmaster tools now. Don’t lean on outdated guides that still push Host in robots.
Migrating URLs and don’t want redirect chains?
We’ll map 301 vs temporary codes, merge https/www, and verify one-hop jumps after deploy.
Discuss the task