Skip to content
Webmaster Tools
Inspect & debugHTTP Status Codes301 Moved Permanently

301 Moved Permanently

What a 301 Moved Permanently redirect means, how to set one up in nginx, Apache, Cloudflare and Express, how browsers cache it and how Google treats it.

All status codes

What 301 means

The resource has a new, permanent URL, given in the Location header. 301 is defined in RFC 9110 §15.4.2. Clients should follow it now and use the new URL from then on; links and bookmarks should be updated.

HTTP/1.1 301 Moved Permanently
Location: https://www.example.com/new-page
Content-Length: 0

The method can change. For historical reasons RFC 9110 allows a user agent to turn a POST into a GET when following a 301, and browsers do exactly that, dropping the body. For pages that's harmless. For an API endpoint or form target that must still receive the POST, use 308 Permanent Redirect.

It's cached. A 301 is cacheable by default, and browsers keep it without any Cache-Control header, often until the cache is cleared. A wrong 301 can follow your visitors around long after you fix the server, so test with a non-cached client first, or ship it with a short Cache-Control: max-age until you're sure.

When to use it

  • Moving from HTTP to HTTPS, or from one domain to another.
  • Choosing one hostname (www or not) and one trailing-slash style.
  • Renaming or restructuring URLs, and merging duplicate pages into one.

How to set it up

nginx:

server {
    listen 80;
    server_name example.com www.example.com;
    return 301 https://www.example.com$request_uri;
}
location = /old-page { return 301 /new-page; }

Apache (.htaccess or vhost):

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

Cloudflare: Redirect Rules (single redirects) or Bulk Redirects, with status 301; "Always Use HTTPS" also sends a 301. Express: res.redirect(301, '/new-page') (the default without a status is 302).

Common mistakes

  • Chains: http://example.com → https://example.com → https://www.example.com → final page. Redirect every old variant straight to the final URL.
  • Loops between two rules, for example an HTTPS redirect at the CDN fighting an HTTP redirect at the origin.
  • Redirecting all removed pages to the home page. Google treats that as a soft 404; return 404 or 410 unless there's a real replacement.
  • Dropping the path or query string in a domain move, so every old deep link lands on the home page.

301 and SEO

Google treats 301 (and 308) as a strong signal that the target should be the canonical URL: it indexes the new URL and consolidates ranking signals there. Google recommends keeping redirects in place for at least a year after a move, and Googlebot follows up to 10 redirect hops before reporting a redirect error, though fewer hops are better for users and crawl efficiency. Update internal links, canonical tags and your sitemap to point at the new URLs directly, and use Search Console's Change of Address tool when you move a whole domain.

Follow every hop of a redirect and see each status with the Redirect Checker.