How browsers and Google follow a 301
For historical reasons, RFC 9110 lets a client change a POST into a GET when it follows a 301. HTTP/1.0 defined 301 as method-preserving, and the spec was later adjusted to allow a POST to be redirected as a GET, matching browser practice. That detail separates 301 from 308: a 308 works like a 301 except that a client may not change a POST into a GET when following it. If the method must not change, RFC 9110 points to 308 instead.
A 301 response is heuristically cacheable, so browsers and caches can store it without explicit cache headers.
What Google does with a 301
Google follows a 301 and treats it as a strong signal that the redirect target should be processed. For Google Search, a permanent redirect is a signal that the target URL should become the canonical URL. Google states that 301 and other permanent redirects do not cause a loss in PageRank. MDN states that search engines credit links pointing at the old URL to the new URL after a 301.
When to use a 301 and how long to keep it
Moved or replaced content. When a page has moved or has a clear replacement, Google recommends a 301 to the new page rather than an error.
Typo URLs. For an inbound link with a typo in the URL, Google has suggested a 301 to the correct URL to keep that traffic.
Site moves. During a website migration, Google says it is important to map each old URL to its URL on the new site.
Duration. For a site move, Google recommends keeping redirects for as long as possible, generally at least one year. The guide to domain migration without losing SEO covers the full sequence.
No way back. Google advises using a permanent redirect only when you are sure the redirect will not be reverted.
On Apache, mod_alias can set a permanent redirect with a single Redirect permanent line. Google warns that redirecting many old URLs to one irrelevant page, such as the homepage, might be treated as a soft 404.
301 redirects in Pagepro's Nexity starter
Nexity, Pagepro's Next.js and Sanity starter, ships a 301 redirect handler. It also has a Redirect document type, so editors manage old-to-new URL pairs in Sanity Studio.
Sources
- RFC 9110: HTTP SemanticsIETF · rfc-editor.org
- RFC 7538: The Hypertext Transfer Protocol Status Code 308 (Permanent Redirect)IETF · rfc-editor.org
- How HTTP status codes, and network and DNS errors affect Google SearchGoogle · developers.google.com
- Redirects and Google SearchGoogle · developers.google.com
- Site Moves and MigrationsGoogle · developers.google.com
- Troubleshoot Google Search crawling errorsGoogle · developers.google.com
- 404 (Page Not Found) errors - Search Console HelpGoogle · support.google.com
- Do 404 errors hurt my site? (Google Search Central Blog, 2011)Google · developers.google.com
- 301 Moved Permanently - HTTP | MDNMozilla (MDN) · developer.mozilla.org