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,302and307The 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 fromPOSTtoGET. This specification also defines the307(Temporary Redirect) status code that doesn't allow the request method to be changed fromPOSTtoGET.See more details below:
Changing the request method from
POSTtoGETThe "historical reasons" in which a user agent may change a request from
POSTtoGETis explained in an Eric Lawrence's post from the IEInternals blog, dated from 19 August 2011.The post quotes the definition of the status code
301from the obsolete RFC 1945, published in May 1996, which defined the HTTP/1.0. The key part from that quote is:Then the author continues:
The need for
308The 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 fromPOSTtoGET.The
308status code is now defined by the RFC 7538 (that obsoleted the RFC 7238).So we have the following:
Choosing the most suitable status code
Michael Kropat put together a set of decision charts that helps to determine the best status code for each situation. See the following for
2xxand3xxstatus codes: