What is HTTP Response Status Code 308 Permanent Redirect?
HTTP response status code 308 Permanent Redirect indicates that the requested resource has been permanently moved to a new URL, and the client should use the new URL for future requests while preserving the original request method.
When is HTTP Response Status Code 308 Permanent Redirect Used?
The 308 status code is used when a resource has been permanently relocated, and all future requests should use the new URL. Unlike 301, it ensures that the HTTP method remains unchanged during redirection.
Example 1: Permanently Redirecting a Resource
# Client sends a PUT request to update a resource. PUT /update-resource HTTP/1.1 Host: www.example.com Content-Type: application/json { "name": "New Name" } # Server Response HTTP/1.1 308 Permanent Redirect Date: Wed, 09 Oct 2024 13:15:00 GMT Server: Apache/2.4.41 (Ubuntu) Location: https://www.example.com/new-update-resource # The server redirects the client to a new permanent location while preserving the PUT method.
Example 2: Redirecting a User Profile to a New URL
# Client sends a GET request to access a user profile. GET /user/12345 HTTP/1.1 Host: www.example.com # Server Response HTTP/1.1 308 Permanent Redirect Date: Wed, 09 Oct 2024 13:17:00 GMT Server: Nginx/1.18.0 Location: https://www.example.com/profile/12345 # The server permanently redirects the client to the new user profile URL. # Future requests should use the new URL.
Summary
The HTTP 308 Permanent Redirect status code is used when a resource has been moved permanently to a new location. It ensures that clients update their bookmarks or records and continue using the same HTTP method when making requests to the new URL.