One Click Answers

In plain English

How to Trace a Redirect Chain

The Simple Answer

To trace a redirect chain, request the original address and record each response: its status code and the Location header that names the next address. Repeat for every hop until you reach a page that returns 200 or an error. Fewer hops is better, and one hop is ideal.

What is a redirect chain?

A redirect is a reply that says the page is somewhere else. The server sends a 3xx status code and a Location header with the new address. The browser then asks for that address. A chain forms when the new address redirects again.

Redirect status codes
CodeNameMeaningRequest method
301Moved PermanentlyThe address has changed for goodMay change to GET
302FoundTemporary moveMay change to GET
303See OtherFetch the result at another addressAlways GET
307Temporary RedirectTemporary moveKept the same
308Permanent RedirectThe address has changed for goodKept the same

For a permanent move, use 301 or 308. For a short-term move, such as a page closed for maintenance, use 302 or 307. The choice tells browsers and other systems whether to remember the new address.

MDN lists 301 and 308 as permanent redirects and 302 and 307 as temporary ones. The 307 and 308 codes keep the request method and body unchanged, while 301 and 302 may change other methods to GET. Each redirect response carries a Location header that names where to go next, which is the address to record at every step.

How do you trace one?

Start with the exact address a visitor would use, including http or https, the www part and the path. Different starting forms often take different routes. Then follow each Location in turn.

Example: a four-hop chain

Assume a visitor opens the plain http form of the old domain, page /sale.

Hop 1: 301 to the secure (https) form of the same page.

Hop 2: 301 to the www form of the same page.

Hop 3: 301 to the new domain, page /sale.

Hop 4: 200 at the final page.

That is 3 redirects before the page loads. One direct 301 would do the same job.

Example: a loop

Assume page A returns 301 to page B.

Page B returns 301 back to page A.

The browser repeats forever and shows a too many redirects error.

Look for two rules, in two places, that disagree with each other.

What mistakes should I avoid when tracing a redirect chain?

  • Checking only the final address in the browser bar and missing the hops before it.
  • Using a temporary code such as 302 for a move that is permanent.
  • Redirecting every old page to the homepage instead of to its matching new page.
  • Letting query strings or the path be dropped during the redirect.
  • Sending visitors from a secure address to a plain http one.
  • Fixing one rule without finding the other rule that causes a loop.

What changes the answer when tracing a redirect chain?

Not every 3xx code is a redirect to a new page. A 304 Not Modified means the cached copy is still current, and it has no new address. Read the status and the headers, not only the first digit.

Results can differ by device, by location and by cache. A browser may remember a permanent redirect and skip the first hop on repeat visits. Test with a checker or a private window to see the real path.

Redirect rules can live in the hosting account, the website software and a domain service at once. Write down where each rule lives before you change any of them.

Slow pages are another reason to cut hops. Each hop is a full round trip before the real page starts to load. If one round trip takes 100 milliseconds, three extra hops add about 300 milliseconds, which is 0.3 seconds. The figure is made up, but the arithmetic is the point: hops add up, so keep them few.

A quick checklist for tracing a redirect chain

  1. Pick the exact starting address, including the http or https part and any www part.
  2. Request it and write down the status code and Location.
  3. Follow each Location until the response is not a redirect.
  4. Count the hops and look for repeated addresses.
  5. Make sure the final page matches the original topic.
  6. Fix rules so old addresses go straight to the final one.
  7. Retest the original address and a few other pages.

Redirect Checker: Paste an address and see every hop, its status code and its destination, ending at the final page.

How we know

How the numbers were worked out. The worked examples use made-up round numbers, calculated with plain arithmetic. Replace them with your own figures; prices, rates and speeds change.

Sources

Published by OneClickAnswers.

You might also wonder...

Try it yourself

  • Redirect CheckerFollow a link step by step and see every redirect and status code.
  • HTTP Header CheckerSee the HTTP response headers a website sends, with a plain summary first and what each one means.
  • Website Health CheckCheck a website for common problems and see what to fix first.

← All articles

Got another question?

Free, no account. Answers show how they were worked out.