Troubleshooting guide
301 vs 302 redirect: which one to use
Use 301 (or 308) when a page has moved for good and 302 (or 307) when the move is temporary. The choice decides which URL search engines keep and how browsers cache it.
4 min read11 sectionsUpdated
On this page
What it means
All four codes send the browser to the Location header’s URL. The difference is intent: permanent redirects tell search engines and browsers to treat the new URL as the real one, temporary ones say the old URL still is. Ranking signals pass through all of them, but only permanent redirects move the indexed URL.
Fixes if you are visiting the site
- If a redirect loops or goes to the wrong place, clear the site’s cache: browsers remember 301s.
- Check the chain with the redirect checker.
Fixes if it is your site
Pick the code by intent, point every old URL straight at its final destination, update internal links and sitemaps to the new URLs, and keep permanent redirects in place for at least a year.
# nginx
return 301 https://example.com$request_uri; # permanent
return 302 /maintenance; # temporary
curl -sI http://example.com | grep -iE "^HTTP|^location"Reading the status code like an engineer
An HTTP status code means the connection worked and a server answered, so the network is fine and the question is which server answered and why. Look at the response headers: Server, Via and CDN-specific headers (cf-ray, x-cache) show whether a CDN, a proxy or your application produced it, and the body format usually confirms it. Then reproduce the exact request with curl, including method, headers and body, and compare it with a request that works. Monitoring should alert on unexpected codes for important URLs, and on rates of 4xx and 5xx rising after a deploy, rather than on every single error.
How site owners catch this before visitors do
Most visitors who hit 301 vs 302 redirect leave without telling you. An uptime check every minute, with a keyword assertion on the page and an SSL check on every run, turns this from a support ticket into an alert. Keep the history: errors that come and go (one region, one server behind a load balancer, one in twenty requests) only make sense on a timeline. Put the result on a status page so people stop guessing. You can test any address now with the free website down checker.
Check it now, free
- Meta tag checker: Title, description, Open Graph and a Google preview.
Related reading
- What is AIOps?: AIOps explained: what AI for IT operations does well, where it falls short, practical uses such as noise reduction and change analysis.
- What is single pane of glass monitoring?: Single pane of glass monitoring explained: one view for all your monitoring data, what it realistically delivers, the trade-offs and how to get the benefits.
- The USE method: The USE method for resources: utilization, saturation and errors for CPU, memory, disk, network and connection pools, with a checklist and example thresholds.
- 410 Gone: what it means and when to use it: 410 Gone explained: how it differs from 404, how search engines treat it, when to remove pages with 410, and how to fix a 410 you did not expect.
- EADDRINUSE: address already in use and how to fix it: Fix EADDRINUSE in Node.js and other servers: find which process holds the port, handle old processes after a crash and avoid race conditions in restarts.
- Docker "port is already allocated": how to fix it: Fix Docker "Bind for 0.0.0.0 failed: port is already allocated": find the process or container on the port, clear stale containers and change mappings.
Watch your own site and services with VitalRix
Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.