HTTP

HTTP 307 Temporary Redirect vs 308 Permanent Redirect

Both 307 and 308 preserve the HTTP method during a redirect, but they differ in permanence. A 307 is temporary (the client should keep using the original URL), while a 308 is permanent (the client should update its references to use the new URL).

Descrição

The resource temporarily resides at a different URL. Unlike 302, this guarantees the HTTP method will NOT be changed.

Quando você o vê

When you need a temporary redirect that preserves the request method (POST stays POST).

Como corrigir

Follow the Location header using the same HTTP method.

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.

307 is temporary — browsers do not cache the redirect and the original URL remains canonical.

2.

308 is permanent — browsers cache the redirect and search engines transfer ranking to the new URL.

3.

Both preserve the HTTP method and request body, unlike 301/302 which may rewrite POST to GET.

4.

307 is ideal for maintenance windows or temporary API migrations.

5.

308 is ideal for permanent API endpoint renames where clients send non-GET requests.

Quando usar qual

Use 307 for temporary method-preserving redirects such as maintenance rerouting or load balancing. Use 308 for permanent method-preserving redirects such as API versioning or endpoint renames. Think of 307 as the temporary counterpart to 308, just as 302 is the temporary counterpart to 301.

Saiba mais