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 |