HTTP Status 308 - Permanent Redirect

Der HTTP-Status-Code 308 Permanent Redirect signalisiert eine permanente Weiterleitung, bei der Client die gleiche HTTP-Methode für Redirect-Request verwenden muss. Kombiniert permanente Semantik von 301 mit Method-Preservation von 307. Moderne Alternative zu 301 für POST/PUT/PATCH API-Endpoints.

Typ

Response-Status-Code

Syntax

Der Status Code wird mit Location Header für permanente Method-preserving Redirect zurückgegeben.

http
HTTP/1.1 308 Permanent Redirect
Location: https://api.example.com/v2/endpoint

Direktiven

Der 308 Permanent Redirect Status Code wird für permanente Redirects mit Method-Preservation verwendet.

Permanent Method-Preserving Redirect
Kombiniert Permanenz von 301 (neue URI für alle zukünftigen Requests) mit Method-Preservation von 307 (POST bleibt POST). Client sollte neue URI speichern und gleiche Method verwenden.
Cacheable
308 Redirects sind cacheable wie 301. Caches und Browsers können Redirect langfristig speichern. Reduziert Server-Last für migrated API-Endpoints.
API Migration
Ideal für API-Endpoint-Migrationen wo Method und Body beibehalten werden müssen. Search Engines übertragen Rankings wie bei 301.

Beispiele

Nachfolgend finden Sie praktische Anwendungsbeispiele für Status 308.

Beispiel 1 API Endpoint Migration

http
POST /api/v1/orders HTTP/1.1
Host: api.example.com
Content-Type: application/json

{"product_id": 42, "quantity": 2}

HTTP/1.1 308 Permanent Redirect
Location: /api/v2/orders
Cache-Control: max-age=31536000
Sunset: Sun, 01 Jan 2026 00:00:00 GMT

Beispiel 2 Domain Migration with POST

http
PUT /api/users/123 HTTP/1.1
Host: old-api.example.com
Content-Type: application/json

{"email": "newemail@example.com"}

HTTP/1.1 308 Permanent Redirect
Location: https://api.example.com/api/users/123

Beispiel 3 Webhook Endpoint Move

http
POST /webhooks/stripe HTTP/1.1
Host: legacy.example.com
Content-Type: application/json

{"event": "payment.success", "data": {...}}

HTTP/1.1 308 Permanent Redirect
Location: https://webhooks.example.com/stripe
X-Migration-Notice: Legacy endpoint deprecated

API Migration Permanent Redirect Flow

308 Permanent Redirect für API Endpoint Migration mit Method Preservation

Vorteile für die Systemarchitektur

  • Safe API Migrations: Permanente API-Endpoint-Migrations mit garantierter Method/Body-Preservation. Clients können Redirects folgen ohne Request neu zu bauen.
  • Cacheable Redirects: 308 Responses werden von Clients, Load Balancers und CDNs gecacht. Reduziert Last auf deprecated Endpoints nach Migration-Phase.
  • SEO-Safe POST Migrations: Search Engines übertragen Rankings zu neuer URL wie bei 301, aber ohne Method-Change-Risk. Ideal für Public APIs mit POST-Endpoints.

Spezifikation

RFC 9110, Section 15.4.9 – HTTP Semantics https://www.rfc-editor.org/rfc/rfc9110.html#name-308-permanent-redirect

Weitere Spezifikationen

HTTP Status 301 - Moved Permanently, HTTP Status 307 - Temporary Redirect, Location Header