301 Redirects: When to use them, when to avoid them, and how to set them up
A 301 redirect tells browsers and search engines: "This page has moved permanently. Here's where to find it now." Done right, you preserve your traffic and ranking. Done wrong, you create redirect chains, infinite loops, and slow page loads. Here's what to actually do.
What a 301 actually is
HTTP status code 301 means Moved Permanently. When a browser or crawler hits a URL that returns a 301, it gets an instruction: "stop looking here, go to this other URL instead, and update your records."
For SEO, the important word is permanently. Search engines treat a 301 as a signal to transfer your old URL's ranking power, backlinks, and indexed status to the new URL. Over the following weeks, search engines remove the old URL from their index and replace it with the new one.
301 vs 302 vs other redirect types
- 301 (Moved Permanently): use this when the change is permanent. Search engines transfer SEO signals to the new URL.
- 302 (Found / Temporary): use when the old URL will come back. Search engines keep the old URL in the index and don't transfer ranking power. Good for A/B tests and short maintenance pages.
- 307 (Temporary Redirect): like 302 but stricter about preserving the HTTP method. Most people don't need this.
- 308 (Permanent Redirect): like 301 but strict about preserving method. Increasingly the modern default, though 301 is still understood by everything.
- Meta refresh:
<meta http-equiv="refresh" content="0; url=/new">. Avoid. Slow, bad for SEO, no signal transfer. - JavaScript redirect:
window.location = '/new'. Same problems as meta refresh. Use only as a fallback inside a JS app.
In 95% of real-world cases, the answer is a 301. Use 302 only when you genuinely mean "this is temporary."
When you should use a 301
- You moved a page.
/about-us→/about. - You restructured a section.
/category/foo/post-1→/blog/2026/post-1. - You changed your domain.
oldsite.com/anything→newsite.com/anything. - You enforced HTTPS.
http://yoursite.com/*→https://yoursite.com/*. - You picked a canonical URL form.
yoursite.com→www.yoursite.com(or the opposite). Trailing slashes, capitalization — pick one form and 301 everything else to it. - You deleted a page that had backlinks. Redirect to the closest related page so the backlinks still pass value. (Don't redirect everything to the homepage; search engines often treat that as a soft 404.)
When NOT to use a 301
- You're A/B testing two versions of the same page. Use 302 or rel="canonical".
- The page is temporarily down for maintenance. Use 503 (Service Unavailable). 301-ing to a "maintenance" page tells search engines the old URL is permanently gone, which is bad if you want it back.
- You want to "redirect" inside a single-page app. Use client-side routing. 301 is a server response, not a navigation gimmick.
- To consolidate weak pages. Sometimes merging is right, but redirecting many thin pages to one strong page can look manipulative if done in bulk. Be thoughtful.
Don't redirect to the homepage
If you delete /blue-widgets, redirecting it to your homepage tells search engines "this page is the homepage now", which is wrong. Search engines often treat homepage redirects as soft 404s. Redirect to the most relevant existing page (e.g. /widgets) or return a clean 404 if no equivalent exists.
Where you set them up
Where the redirect lives depends on what runs your site:
- Apache (most shared hosting, cPanel):
.htaccessfile in the site root - nginx (most VPS / dedicated hosts): server block inside
nginx.confor a site config file - Netlify: a plain
_redirectsfile in your repo root - Cloudflare Pages: same
_redirectsfile format as Netlify - Vercel:
redirectskey invercel.json - Cloudflare Workers: JavaScript that runs at the edge for any zone
- WordPress: a redirection plugin, or edit
.htaccessdirectly if you're comfortable
Copy-paste rules for each platform
Apache .htaccess
RewriteEngine On Redirect 301 /about-us /about Redirect 301 /blog/old-slug /blog/new-slug
nginx
server {
location = /about-us { return 301 /about; }
location = /blog/old-slug { return 301 /blog/new-slug; }
}
Netlify / Cloudflare Pages _redirects
/about-us /about 301 /blog/old-slug /blog/new-slug 301
Cloudflare Workers
const REDIRECTS = new Map([
["/about-us", "/about"],
["/blog/old-slug", "/blog/new-slug"],
]);
export default {
async fetch(request) {
const url = new URL(request.url);
const target = REDIRECTS.get(url.pathname);
if (target) return Response.redirect(new URL(target, url), 301);
return fetch(request);
}
};
Generate redirect rules in 30 seconds
Paste your old → new URL pairs once. Get Apache, nginx, Cloudflare, and Netlify rules in one click.
Common mistakes
- Redirect chains. Page A → B → C → D. Each hop adds latency and dilutes ranking transfer. Always redirect to the final destination, not through an intermediate URL.
- Infinite loops. Page A → B and B → A. Browsers throw a "too many redirects" error and search engines deindex both.
- Forgetting the trailing slash. If your canonical is
/about/but your redirect targets/about, you'll create an extra hop when the server normalizes the path. Pick a form and use it consistently. - HTTPS-on-HTTP redirect missing. Always redirect
http://*tohttps://*at the server level. Don't rely on the browser to upgrade. - Wildcard redirects to the homepage.
RedirectMatch 301 ^/.* /sends every URL on your site to the homepage. Did this happen to you? Check your.htaccessfor accidental greedy patterns.
How long does it take search engines to update?
Search engines recrawl high-traffic pages within hours and low-traffic pages within weeks. For most sites, the new URL starts appearing in search results within 1–4 weeks of setting up the 301. The old URL drops out of the index over the same window.
To speed things up, submit the new URL via search-engine webmaster tools → URL Inspection → Request Indexing. This nudges search engines to check the new URL sooner.