HTTP

HTTP 301 Moved Permanently vs 307 Temporary Redirect

301 and 307 differ in both permanence and method handling. A 301 is permanent and may change the HTTP method, while a 307 is temporary and always preserves the method. Choosing between them depends on whether the move is permanent and whether the method matters.

คำอธิบาย

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.

เมื่อคุณพบเห็น

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

วิธีแก้ไข

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

คำอธิบาย

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

เมื่อคุณพบเห็น

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

วิธีแก้ไข

Follow the Location header using the same HTTP method.

ความแตกต่างหลัก

1.

301 is permanent — search engines transfer link equity and browsers cache the redirect.

2.

307 is temporary — the original URL retains its search ranking.

3.

301 may rewrite POST to GET; 307 always preserves the original HTTP method.

4.

301 is the most common redirect for URL migrations; 307 is used for temporary rerouting.

5.

For a permanent method-preserving redirect, use 308 instead of either.

ควรใช้อันไหนเมื่อไร

Use 301 when a page has permanently moved and you only serve GET requests. Use 307 when the redirect is temporary and you need to preserve the HTTP method (e.g., redirecting a POST request during maintenance). If you need both permanent and method-preserving, use 308.

เรียนรู้เพิ่มเติม