HTTPError.net

The fastest way to diagnose, understand, and fix any HTTP status code

308 Permanent Redirect

Fault: Neither
TL;DR

Permanent redirect that preserves the request method.

The resource has permanently moved to another URL, and the request method should not change.

What HTTP 308 Permanent Redirect Means

The resource has permanently moved to another URL, and the request method should not change.

Permanent redirect that preserves the request method.

Common Causes

What Visitors Should Do

Notes for Developers

308 vs 301 vs 307

CodePermanent?Method on redirectTypical use
301YesMay change POST to GETMoved pages, domain or HTTPS migrations
302NoMay change POST to GETShort-term moves, login redirects
303NoAlways GETRedirect after a form POST
307NoMust keep method and bodyTemporary moves of APIs or forms
308YesMust keep method and bodyPermanent moves of APIs or forms

RFC 9110 allows clients to switch a POST to GET on a 301 or 302 for historical reasons, which is why 307 and 308 exist.

How to Send a 308

# Nginx
location /api/v1/ { return 308 /api/v2/; }

Returning a 308 Permanent Redirect (Code Examples)

If you build APIs or web apps, here is how to send an HTTP 308 response and how to test for it:

Node.js (Express)

app.get('/resource', (req, res) => {
  res.status(308).json({ error: 'Permanent Redirect' });
});

Python (Flask)

@app.route('/resource')
def resource():
    return jsonify(error='Permanent Redirect'), 308

PHP

<?php
http_response_code(308);
header('Content-Type: application/json');
echo json_encode(['error' => 'Permanent Redirect']);

Check the status with curl

curl -I https://example.com/resource
# Look for: HTTP/1.1 308 Permanent Redirect

Frequently Asked Questions

What does HTTP 308 Permanent Redirect mean?

Permanent redirect that preserves the request method. In short: The resource has permanently moved to another URL, and the request method should not change.

How should I handle an HTTP 308 Permanent Redirect response?

Use instead of 301 to preserve HTTP method. Set Location header.

Official Specification

The 308 Permanent Redirect status code is defined in RFC 9110 Section 15.4.9 (originally RFC 7538).

View the IANA HTTP Status Code Registry →