308 Permanent Redirect

The resource has moved for good, and requests must be repeated at the new URL with the same method and body.

What 308 means

A 308 combines two properties. Like a 301 it is permanent: the URL in Location replaces the old one, and clients should update what they have stored. Like a 307 it keeps the method: a POST is repeated as a POST with its body, never rewritten to GET.

It is also cacheable by default, as a 301 is. A client may remember the redirect and stop asking the old URL, even when the response has no Cache-Control header.

When to choose 308 over 301

Use 308 when the old URL receives requests that are not GET:

  • an API that moves to a new host, base path or version prefix;
  • forcing HTTPS on endpoints that accept POST or PUT, where a 301 would turn the redirected call into an empty GET;
  • a renamed form or upload endpoint.

For ordinary web pages, 301 remains the usual choice. Every client has understood it for decades, and Google treats 301 and 308 the same way: as a strong signal that the target URL replaces the old one.

It is the wrong code for a temporary move (use 307), and after a form submission where the browser should load a result page with GET (use 303).

Clients that do not know 308

308 is much younger than the other redirect codes, and the specification itself warns that it might not be recognised everywhere. A client that does not know a status code has to treat it as the generic code of its class, here 300, and it will not follow the redirect automatically.

Current browsers and mainstream HTTP libraries all support 308. The risk lies with old embedded devices, legacy scripts and some webhook senders, which often do not follow redirects of any kind. Two precautions:

  • Put a short body in the response with the new URL, so that a person reading a log can see where to go.
  • For webhooks and partner integrations, do not rely on the redirect. Have the sender's configured URL changed, and keep the 308 as a safety net.

Sending a 308

  • nginx: return 308 https://api.example.com$request_uri;. Versions before 1.13.0 do not treat 308 as a redirect.
  • Apache: Redirect 308 "/v1" "https://api.example.com/v2". The keywords stop at permanent (301), so use the number.

Check it with a request of the right method, because a HEAD or GET test tells you nothing about body handling: curl -i -X POST -d '{}' https://example.com/v1/orders should show the 308, and adding -L should deliver a POST to the new URL.

Caching, and taking a 308 back

The same caution applies as for a 301. Once clients have cached a permanent redirect they may never revisit the old URL, so a mistake is slow to undo. Roll out with a 307 first, or send Cache-Control: max-age=3600 with the 308 until you are sure of the target.

As with any redirect, a Location without a fragment inherits the fragment of the original URL, and a relative Location is resolved against it.

308 compared with 301, 307 and 302

CodeLastsMethodCacheable by default
308 Permanent RedirectPermanentKeptYes
301 Moved PermanentlyPermanentPOST may become GETYes
307 Temporary RedirectTemporaryKeptNo
302 FoundTemporaryPOST may become GETNo

Example 308 response

HTTP/1.1 308 Permanent Redirect
Location: https://api.example.com/v2/orders
Content-Type: text/plain
Content-Length: 54

Moved permanently to https://api.example.com/v2/orders

A client that understands 308 repeats the request, method and body unchanged, at the new URL and uses that URL from then on. The plain-text body is for anything that does not.

Defined in RFC 9110, section 15.4.9.

Questions

What is the difference between 308 and 301?

Both are permanent redirects. After a 301 a client may change a POST into a GET and drop the body, which browsers do. A 308 forbids that: the request is repeated with the same method and body.

Does Google treat a 308 like a 301?

Yes. Google documents 308 as equivalent to 301: it follows the redirect and takes it as a strong signal that the target URL should be used in place of the old one.

Do all clients support 308?

All current browsers and common HTTP libraries do. Very old clients may not recognise it and will then not follow the redirect, and many webhook senders do not follow redirects at all, so update the URL at the sender where you can.

Can I undo a 308 redirect?

You can remove it from the server, but clients that cached it may keep going to the new URL without asking again. Limit the damage in advance by sending Cache-Control: max-age with the redirect while you are still testing.