Skip to content

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

Key points

  • 301/308 = permanent: search engines index the new URL.
  • 302/307 = temporary: the old URL stays indexed.
  • 307/308 keep the method; 301/302 may turn POST into GET.
  • Browsers cache 301s hard: test before you ship.

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.

Common causes

  • Use 301/308 for HTTP→HTTPS, domain moves, changed slugs, merged pages.
  • Use 302/307 for maintenance pages, A/B tests, geo or login redirects.
  • Use 303 after a form POST to show a result page.
  • Avoid chains: each extra hop costs time and crawl budget.

Fixes if you are visiting the site

  1. If a redirect loops or goes to the wrong place, clear the site’s cache: browsers remember 301s.
  2. 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.

bash
# 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.

Frequently asked questions

Does a 302 hurt SEO?

Not directly, but the old URL stays indexed; use 301 for permanent moves.

Can I undo a 301?

Yes, but browsers that cached it keep redirecting until their cache clears.

What is 308?

A permanent redirect that keeps the request method and body.

Check it now, free

  • 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.