HTTP

HTTP 301Moved Permanently

HTTP 301 Moved Permanently tells the client that the resource now lives at the URL in the Location header and that future requests should go there directly. Browsers cache 301s aggressively, and search engines transfer ranking signals to the new URL, which makes it the right code for site migrations and HTTP-to-HTTPS redirects.

BlackhawkHub Editorial · Updated

What 301 means

The server is saying: "this resource has moved for good; use the new address from now on." Clients follow the Location header automatically and may update bookmarks or links. Search engines treat the new URL as canonical and move the old URL's indexing signals to it.

Behaviour details

  • Caching. RFC 9110 makes 301 cacheable by default. Chrome and Firefox remember a 301 until their cache is cleared, so a mistaken 301 is hard to retract for existing visitors.
  • Method change. Historically clients converted POST to GET when following a 301, and the spec still permits it. Use 308 semantics (Permanent Redirect) when the method must be preserved.
  • Chains. Each hop costs a round trip and dilutes crawl efficiency. Redirect directly to the final URL.

Common uses

  1. HTTP → HTTPS on port 80 to 443.
  2. www ↔ non-www canonicalisation.
  3. URL restructuring during a redesign.
  4. Domain migration, page by page.
  5. Trailing-slash normalisation.

Configuring

Apache (.htaccess or virtual host):

apache
Redirect 301 /old-page/ /new-page/
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

nginx:

nginx
location = /old-page/ { return 301 /new-page/; }
server { listen 80; return 301 https://$host$request_uri; }

Verifying

cmd
curl -I http://example.com/old-page/

Expect HTTP/1.1 301 Moved Permanently and a Location: line. curl -IL follows the chain and prints every hop, which reveals redirect loops and chains. The 301 vs 302 guide covers choosing between the two.

Frequently asked questions

How do I undo a 301?

Serve a new redirect from the target back, and accept that browsers which cached the old 301 will keep following it until their cache clears. This is why 301s should only be used for changes that are genuinely permanent.

Does a 301 lose ranking?

Google has stated that 301 redirects do not lose PageRank. Signals consolidate to the destination, provided the destination is relevant and the redirect is direct, not a chain.

301 or 308?

Both are permanent. 308 guarantees the method and body are preserved (a POST stays a POST). 301 allows clients to switch to GET. For ordinary page moves 301 is universal; for API endpoints 308 is safer.

Sources