308 Permanent Redirect는 리소스가 영구히 새 URL로 이동했음을 알리면서, 클라이언트가 원래의 HTTP 메서드와 본문을 그대로 유지해 재요청하도록 요구합니다. 한마디로 301의 메서드 보존 버전입니다.
301이 과거 관행상 POST를 GET으로 바꿔 처리되기도 했던 문제를 없앴기 때문에, POST·PUT 같은 비-GET 요청의 영구 이전에 정확한 코드입니다.
PUT /v1/items/9 HTTP/1.1
Host: api.example.com
Content-Type: application/json
{"name":"Widget"}HTTP/1.1 308 Permanent Redirect
Location: https://api.example.com/v2/items/9
Content-Length: 0
(client re-sends the SAME PUT with its body to the new URL, permanently)# permanently move /v1/* to /v2/* keeping method + body
location /v1/ {
return 308 /v2/$uri;
}app.all('/v1/items/:id', (req, res) => {
res.redirect(308, `/v2/items/${req.params.id}`);
});