308 Permanent Redirect
Redirect - Permanent, preserves HTTP method
HTTP 308 Permanent Redirect
What It Means
The HTTP 308 Permanent Redirect indicates that the resource has permanently moved to a new URL. Like 301, it's permanent and passes SEO value. Unlike 301, it guarantees the HTTP method won't change.
308 vs 301
| Aspect | 301 | 308 |
|---|---|---|
| Permanence | Permanent | Permanent |
| SEO value transfer | Yes | Yes |
| Method preservation | May change POST→GET | Guaranteed preserved |
| Browser support | Universal | Modern browsers |
When to Use 308
- API endpoint migration: Permanently moving API endpoints that receive POST/PUT/DELETE
- Domain migration with APIs: Moving api.old.com to api.new.com
- URL restructuring: When APIs with non-GET methods need permanent redirects
Example Response
POST /api/v1/users HTTP/1.1
Host: old-api.example.com
Content-Type: application/json
{"name": "John"}
---
HTTP/1.1 308 Permanent Redirect
Location: https://api.example.com/v2/users
(Client re-sends POST with same body to new URL)
Complete Redirect Matrix
| Code | Permanent | Method | Use Case |
|---|---|---|---|
| 301 | Yes | May change | GET/HEAD redirects, SEO |
| 302 | No | May change | Temporary, GET/HEAD |
| 307 | No | Preserved | Temporary POST/PUT |
| 308 | Yes | Preserved | Permanent POST/PUT |
Implementation
Nginx
location /api/v1/ {
return 308 https://api.example.com/v2$request_uri;
}
Express.js
app.all('/api/v1/*', (req, res) => {
const newUrl = req.url.replace('/v1/', '/v2/');
res.redirect(308, `https://api.example.com${newUrl}`);
});
Browser Support
308 is supported in all modern browsers (Chrome, Firefox, Safari, Edge). For very old browsers, consider using 307 for temporary redirects or handling POST separately from GET.