308 Permanent Redirect
HTTP response status code 308 Permanent Redirect is returned by the server to indicate that the requested resource has been permanently moved to a new location.
Usage
When the 308 Permanent Redirect status code is received, clients are expected to update their stored links to the new URI. This will be specified by the Location HTTP header and can be used by the client for automatic redirection.
This message might be sent by servers that have migrated to a new domain, or have reorganized their internal file structure, and do not plan on reverting to the former URI.
The 308 Permanent Redirect status code differs from the 301 Moved Permanently status code in that the client is required to make an identical HTTP request to the specified Location, whereas 301 Moved Permanently allows for the client to change the HTTP request method. For example, in response to a POST HTTP request by the client, a 301 Moved Permanently HTTP response signals to the client that it is okay to change the POST HTTP request to a GET HTTP request for the subsequent HTTP request. However, 308 Permanent Redirect status code stipulates that if it was originally a POST HTTP request then the follow-up HTTP request also has to be a POST HTTP request.
Example
In the example, the client attempts to retrieve an HTML resource. The server responds to say that the resource has permanently moved to a new URI and includes it in the Location HTTP header. Client-side, a message is presented in the message body to suggest updating the relevant bookmarks, however this is seldom visible in modern browsers which straight away redirect to the new location.
Request
GET /news.html HTTP/1.1
Host: www.example.re
Response
HTTP/1.1 308 Permanent Redirect
Location: http//www.example.re/feeds/news.html
Content-Type: text/html; charset=UTF-8
Content-Length: 150
<h1>The Newsfeed has moved</h1>
<body>
The newsfeed has moved permanently to <a href=/feeds/news.html>here</a>. Please update your bookmarks.
</body>
Code references
.NET
HttpStatusCode.PermanentRedirect
Rust
http::StatusCode::PERMANENT_REDIRECT
Rails
:permanent_redirect
Go
http.StatusPermanentRedirect
Symfony
Response::HTTP_PERMANENTLY_REDIRECT
Python3.5+
http.HTTPStatus.PERMANENT_REDIRECT
Apache HttpComponents Core
org.apache.hc.core5.http.HttpStatus.SC_PERMANENT_REDIRECT
Angular
@angular/common/http/HttpStatusCode.PermanentRedirect
Takeaway
The 308 Permanent Redirect status code indicates that the resource has moved to a new location that is specified within the HTTP response. Clients are expected to update their internal data accordingly and when making the follow-up HTTP request, they are not to change the HTTP request method.