301 vs 308 Redirect โ Which Should You Use for SEO and APIs
Updated April 2026
Reading this? Verify your fix live. Audit your redirect headers โ EdgeFix
Both 301 and 308 are permanent redirects. The difference is one detail: 301 changes POST to GET on redirect. 308 preserves the original HTTP method. For browser page redirects this does not matter โ for APIs it does.
The difference visualised
# 301 Moved Permanently POST /old-endpoint โ 301 โ GET /new-endpoint โ method changed! # 308 Permanent Redirect POST /old-endpoint โ 308 โ POST /new-endpoint โ method preserved โ
When to use each
| Situation | Use | Why |
|---|---|---|
| www to non-www | 301 | Browser navigation โ method change irrelevant |
| HTTP to HTTPS | 301 | Browser navigation โ use HSTS instead for repeat visits |
| Old page URL to new URL | 301 | Standard permanent page move |
| Old API endpoint to new | 308 | API clients use POST/PUT โ preserve the method |
| Domain migration | 301 | Standard โ browsers follow automatically |
Config by stack
Nginx โ 301 (page redirect)
server { listen 80; server_name yourapp.com; return 301 https://yourapp.com$request_uri; # HTTP โ HTTPS
}
server { server_name www.yourapp.com; return 301 https://yourapp.com$request_uri; # www โ non-www
}
Nginx โ 308 (API endpoint move)
location /api/v1/submit { return 308 /api/v2/submit; # preserves POST method
}
Vercel (vercel.json)
{ "redirects": [ { "source": "/old-page", "destination": "/new-page", "permanent": true // uses 308 in Vercel }, { "source": "/api/v1/:path*", "destination": "/api/v2/:path*", "permanent": true } ]
}
Cloudflare Redirect Rules
# Rules โ Redirect Rules โ Create Rule # Choose: 301 Moved Permanently or 308 Permanent Redirect # Source: /old-path # Target: /new-path
The full redirect status code map
| Code | Permanent? | Preserves method? | Use for |
|---|---|---|---|
| 301 | โ Yes | โ No (POST โ GET) | Page moves, domain changes |
| 302 | โ No | โ No (POST โ GET) | Temporary redirects (login, auth) |
| 307 | โ No | โ Yes | Temporary API endpoint changes |
| 308 | โ Yes | โ Yes | Permanent API endpoint moves |