301 Moved Permanently: what it means
A 301 is not an error: it tells the client that the resource now lives at a new address, given in the Location header, and that the move is permanent. Browsers follow it without showing anything, caches keep it, and search engines transfer the page's signals to the new address.
The code belongs to the 3xx class and its official name is "Moved Permanently". The page opens the status code list on 301, so you can compare it with its neighbours.
What the response looks like
HTTP/1.1 301 Moved Permanently
Location: https://example.com/new-page
Content-Length: 0Common causes
- Moving a site from http to https, or from www to the bare domain (or the reverse).
- Changing the domain name and keeping the old one pointing to the new site.
- Renaming a page or changing the URL structure, such as /blog/2024/post to /post.
- Forcing a single form of the address: with or without the trailing slash, lower case only.
How to fix it
If you are a visitor
- Nothing to do: the browser follows the redirect by itself and updates the address bar.
- If you see "too many redirects", clear the cookies of that site: a stale cookie can send the page in a loop.
If you run the site or the API
- Redirect old to new in one hop; a chain (A to B to C) wastes time and crawl budget.
- Test with curl -IL to see every hop and its status, and watch for loops.
- Use 308 instead of 301 when the method must be kept: some clients turn a POST into a GET after a 301.
- Update internal links and the sitemap to the final address so that visitors do not depend on the redirect.
Snippets to copy
nginx: http to https and www to the bare domain
server {
listen 80;
server_name example.com www.example.com;
return 301 https://example.com$request_uri;
}Apache and Express
# .htaccess
Redirect 301 /old-page https://example.com/new-page
// Express
app.get('/old-page', (req, res) => res.redirect(301, '/new-page'));Codes it is confused with
| Code | Difference |
|---|---|
| 302 Found | Temporary: keep using the old address; search engines keep the old URL. |
| 307 Temporary Redirect | Temporary, and the request method and body must not change. |
| 308 Permanent Redirect | Permanent like 301, and the method must not change. |
| 304 Not Modified | Not a move: "your cached copy is still good". |
Caching, retries and search engines
Browsers may cache a 301 with no expiry, so a mistaken one can stick on visitors for a long time: test redirects with 302 first, then switch to 301 when you are sure. Google treats a permanent redirect as a strong signal that the target is the canonical address, and follows chains of up to 10 hops, but one hop is the goal.
Look up other status codes
- Open the list and type a number (404) or a word (timeout) in the search box.
- Read the description of the code and copy "301 Moved Permanently" with the button on its card.
- Use the # button to copy a link straight to that code.
Frequently asked questions
What is the difference between a 301 and a 302 redirect?
301 is permanent: the new address replaces the old one in caches and in search results. 302 is temporary: the old address stays the official one and the redirect may go away.
Does a 301 redirect lose SEO value?
Google says that redirects do not lose PageRank by themselves. What hurts is a redirect to an unrelated page, a long chain or removing the redirect too soon.
How do I check a redirect from the command line?
curl -IL https://example.com/old prints the status and Location of every hop until the final answer.