301

Moved Permanently

3xx Redirection

ELI5

This moved for good. Start using the new address from now on.

Server perspective

Use 301 for permanent redirects when moving the resource for good and method preservation is not the main concern.

When to use

  • Return 301 for permanent content moves, canonicalization, and domain migrations
  • Prefer 308 instead when redirected POST, PUT, or PATCH requests must keep the same method and body
  • Permanent URL or domain migrations
  • Canonical URL changes such as path cleanup or site restructuring
  • Permanent redirects for GET/HEAD content where method rewriting is not a concern
  • Moving old documentation pages to durable replacement locations

How to respond

  • Include a Location header with the new URI
  • Keep the target stable so caches, crawlers, and clients are not whipsawed by conflicting permanent redirects

Headers to consider

  • Location
  • Cache-Control

Response body

  • A response body is optional, but the redirect target should be clear from the Location header

Server-side pitfalls

  • Do not use 301 when the move is only temporary
  • Do not assume every client will preserve POST on automatic redirects
  • Temporary redirects where the original URI should stay canonical
  • Non-GET requests where preserving the original method and body matters; use 308 instead
  • After a successful write where the follow-up should be a safe retrieval; use 303 See Other instead
  • Queued or asynchronous operations where the work has not yet completed; use 202 Accepted instead

Examples

Permanent docs URL change

Request:GET https://api.example.test/guides/http-basics
Response:301 Moved Permanently # Headers Location: https://api.example.test/docs/http-basics

The old URL should stop being used and future traffic should move to the new path.

Domain migration

Request:GET https://api.example.test/pricing
Response:301 Moved Permanently # Headers Location: https://example.com/pricing

The resource has a permanent new home and clients can update stored links.

References

Related Status Codes