What a 301 response looks like
Browsers cache a 301, often with no expiry, so a mistaken 301 is hard to take back. If you're not sure the move is final, test with a 302 first.
HTTP/1.1 301 Moved Permanently
Location: https://www.example.com/new-pageSet up a 301 redirect
| Setup | Redirect |
|---|---|
| nginx | return 301 https://www.example.com$request_uri; |
| Apache (.htaccess) | Redirect 301 /old-page /new-page |
| Express | res.redirect(301, "/new-page") |
| PHP | header("Location: /new-page", true, 301); |
| Next.js | { source: "/old-page", destination: "/new-page", permanent: true } in redirects(). Next.js sends 308 for this, which search engines treat like 301. |
301 redirects and SEO
- Google treats a 301 or 308 as a strong signal that the new URL should be the one it shows in results.
- Redirect each old URL to the page that replaces it. Sending everything to the homepage can be treated as a soft 404.
- Point redirects straight at the final URL. Chains such as http → https → www → new page add a request each and can stop crawlers before the end.
- Update internal links, canonical tags and the sitemap to the new URL, so the redirect is only a fallback.
- Keep redirects for a moved site in place for at least a year.
Frequently asked questions
What is the difference between 301 and 308?
Both are permanent. With 301 a client may turn a POST into a GET when it follows the redirect; with 308 it must repeat the same method and body. For ordinary pages either works; for API endpoints that receive POST, use 308.
How do I check whether a URL returns a 301?
Run curl -I https://example.com/old-page. The first line shows the status, and the Location header shows where it points. Add -L to follow the whole chain.
Does a 301 redirect lose ranking?
Google has said that permanent redirects don't lose PageRank. Rankings can still move for a while as Google recrawls the old and new URLs and combines their signals.
More http status code lookup guides
- 502 Bad Gateway: What It Means and How to Fix It
- 504 Gateway Timeout: Causes and Fixes
- 429 Too Many Requests: Meaning, Retry-After and Fixes
- 403 Forbidden: Meaning, Causes and How to Fix It
- 401 Unauthorized: What It Means and How to Fix It
- 500 Internal Server Error: Causes and How to Fix It
- 503 Service Unavailable: Causes and Fixes
- 400 Bad Request: Causes and Fixes (Including Cookie Too Large)
- 404 Not Found: What It Means and How to Fix It
- 302 Found: Temporary Redirects Explained
- 408 Request Timeout: Causes and How to Fix It