The 308 Permanent Redirect HTTP status code indicates that a requested resource has been permanently moved to a new URL, and all future requests should use the new URL. Unlike 301, it preserves the original HTTP method and request body.
When a server responds with status code 308, it must include a Location header containing the new permanent URL.
// HTTP response indicating permanent redirect with method preserved
HTTP/1.1 308 Permanent Redirect
Location: https://example.com/new-endpoint
// Express.js example sending a 308 redirect
app.post("/old-api", (req, res) => {
res.redirect(308, "/new-api");
});
Below demonstrates how a POST request is preserved during a 308 redirect, unlike 301 or 302 which may convert it to GET.
// Fetch API showing method preserved on 308 redirect
fetch("/old-endpoint", {
method: "POST",
body: JSON.stringify({name:"User"})
});
Location header-L flag