What's the difference between HTTP 301
and 308
status codes?
301
(Moved Permanently): This and all future requests should be directed to the given URI.308
(Permanent Redirect): The request and all future requests should be repeated using another URI.
They seem to be similar.
An overview of
301
,302
and307
The RFC 7231, the current reference for semantics and content of the HTTP/1.1 protocol, defines the
301
(Moved Permanently) and302
(Found) status code, that allows the request method to be changed fromPOST
toGET
. This specification also defines the307
(Temporary Redirect) status code that doesn't allow the request method to be changed fromPOST
toGET
.See more details below:
The need for
308
The RFC 7238 has been created to define the
308
(Permanent Redirect) status code, that is similar to301
(Moved Permanently) but does not allows the request method to be changed fromPOST
toGET
.The
308
status code is now defined by the RFC 7538 (that obsoleted the RFC 7238).Se we have the following:
Choosing the most suitable status code
Have a look at the diagram below (extracted from this page):