🏠
308
Permanent Redirect
→
Example HTTP Response
HTTP Response
HTTP/1.1 308 Permanent Redirect
Location: /new-permanent-endpointCommon Causes
- API endpoint permanently moved
- Maintaining POST method during redirect
- Permanent URL restructuring
Technical Details
What does this mean?
Permanent new address, same attitude! The resource moved forever but you can keep doing your thing the same way.
Technical Definition
The resource has permanently moved to another URI, specified in the Location header. Method and body unchanged.
Code Snippets
Ready-to-use code for returning this HTTP status in your application:
Node.js
// Express.js
app.get('/example', (req, res) => {
res.status(308).json({
error: 'Permanent Redirect',
message: 'Your error message here'
});
});
// Native HTTP
const http = require('http');
http.createServer((req, res) => {
res.writeHead(308, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({
error: 'Permanent Redirect',
message: 'Your error message here'
}));
}).listen(3000);When to Use This Code
- Permanent redirect that must preserve the HTTP method (POST stays POST)
- API endpoints that have moved permanently
- Preferred over 301 when method preservation is critical
- Clients should update their references to use the new URL
Related Status Codes
Commonly Confused With