What is the difference between the 301, 302, 307 and 308 redirect codes?
Short answer
Redirect codes are 3xx responses that inform the client with the Location header that the requested resource is at another address. 301 (Moved Permanently) and 308 (Permanent Redirect) are permanent, 302 (Found) and 307 (Temporary Redirect) are temporary. With 307 and 308, the client sends the method and the body to the new address without changing them; with 301 and 302, browsers can change POST to GET; 303 (See Other), on the other hand, says that the new address is to be requested with GET. In TR7, the code is selected in the Location Redirection action, in its Redirect Code field, and in the Redirect to HTTPS action, in its Redirect Scheme Code field; in both, the default is 301. The HTTP → HTTPS protocol on the Frontend always returns 301; in the Redirect Code field of the Redirect action in Bot/DDoS protection, the default is 302.
Where It Is Used in TR7
| Where | Field / label | What for |
|---|---|---|
| Load Balancer → Actions (Policy Actions) → Location Redirection action | Redirect Code: 301, 302, 303, 307, 308 (default 301) | Redirecting the request to another address |
| Load Balancer → Actions (Policy Actions) → Redirect to HTTPS action | Redirect Scheme Code (default 301) | Redirecting the HTTP request that matches the condition to HTTPS; 300–308 are offered in the list, and 301, 302, 303, 307 or 308 is selected for a redirect |
| Load Balancer → Load Balancer vService List → HTTP vService form → Frontend | Protocol → Redirect → HTTP → HTTPS | Redirecting all unencrypted requests coming to the Frontend to HTTPS with 301; no code is selected |
| Bot/DDoS → Bot/DDoS Protected vService List → Bot/DDoS Management → Bot Protection → Action Rules | Action: Redirect → Redirect Code (default 302) | Sending the client whose bot score exceeds the threshold to another address |
| Same screen → IP Reputation Protection | Action: Redirect → Redirect Code (default 302) | Sending the client coming from a bad-reputation IP to another address |
Comparison
| Code | Name | Permanence | Are the method and body preserved |
|---|---|---|---|
| 301 | Moved Permanently | Permanent | No; browsers can change POST to GET |
| 302 | Found | Temporary | No; browsers can change POST to GET |
| 303 | See Other | Temporary | No; the new address is requested with GET |
| 307 | Temporary Redirect | Temporary | Yes |
| 308 | Permanent Redirect | Permanent | Yes |
The definition of the codes is in the RFC 9110 · Redirection 3xx section. Redirecting one URL to another URL: How do I redirect a specific URL to another URL with a 301/302?
Common Misconceptions
- "301 can be used for a temporary campaign." Browsers and search engines treat 301 as permanent, and browsers can cache it; for a temporary redirect, 302 or 307 is selected.
- "Moving a form that sends POST with 301 causes no problem." With 301 and 302, the browser can change POST to GET; if the method and the body need to be preserved, 307 or 308 is used.
- "The code can be changed in the HTTP → HTTPS frontend protocol." This protocol always returns 301; if a different code or a condition-based redirect is needed, the Redirect to HTTPS action is used (What is the difference between the HTTP → HTTPS frontend protocol option and the Redirect to HTTPS action?).
How it is done in the documentation
