HTTP

HTTP 301 Moved Permanently vs 308 Permanent Redirect

Both 301 and 308 signal a permanent redirect, but they differ in how they handle the HTTP method. A 301 allows clients to change the request method (commonly POST to GET), while 308 strictly preserves the original method and request body.

Descrição

The resource has been permanently moved to a new URL. All future requests should use the new URL. Search engines will transfer link equity to the new URL.

Quando você o vê

After domain migrations, URL restructuring, or when consolidating duplicate URLs.

Como corrigir

Update links and bookmarks to the new URL in the Location header. For SEO, this is the preferred redirect for permanent moves.

Descrição

The resource has been permanently moved. Like 301, but guarantees the HTTP method will NOT be changed.

Quando você o vê

For permanent URL changes where POST requests must remain POST.

Como corrigir

Update all references to the new URL. The HTTP method is preserved.

Diferenças principais

1.

301 may rewrite POST to GET — most browsers historically convert the method on redirect.

2.

308 guarantees the HTTP method is preserved — a POST redirect stays POST with the same body.

3.

Both are permanent, so search engines transfer link equity to the new URL.

4.

308 was introduced in RFC 7538 specifically to fix the method-rewriting ambiguity of 301.

5.

301 has broader legacy compatibility; 308 requires HTTP/1.1-aware clients.

Quando usar qual

Use 301 for simple permanent redirects where the method does not matter (e.g., page moves, domain changes). Use 308 when you need to permanently redirect a POST, PUT, or DELETE endpoint and the method and body must be preserved, such as API endpoint migrations.

Saiba mais