ShieldX Toolly
Open a tool Donate
Home Home
Blog Blog
FAQ FAQ
Open a tool Donate
Back to cheatsheets
Web Security

Redirect Chain Tracing

Trace HTTP redirect hops, detect loops, and identify the final destination URL.

2 snippets Beginner redirect-chain-checker
redirect301302loop detectioncurl

What you'll learn

  • Trace redirects with curl
  • JavaScript redirect tracer

How to use these snippets

  1. Click the Copy button next to any snippet to copy it to your clipboard.
  2. Paste the code into your project, IDE, or terminal.
  3. Replace placeholder values (like example.com or your-secret) with your actual data.
  4. Review the code comments for important security notes and caveats.
  5. Try the interactive related tool to see the concept in action.
Code Snippets

Copy-paste code snippets

2 ready-to-use snippets for redirect chain tracing. Click copy and paste into your project.

Trace redirects with curl
                # Follow redirects and show each hop
curl -L -o /dev/null -w \
  '%{url_effective} → %{http_code}\n' \
  https://example.com

# Verbose redirect trace
curl -vIL https://short.url/abc123 2>&1 | \
  grep -i 'location:\|HTTP/'

# Detect redirect loops
curl -L --max-redirs 10 https://example.com
# If max-redirs is hit, you have a loop
              
JavaScript redirect tracer
                async function traceRedirects(url) {
  const hops = [];
  let current = url;
  const visited = new Set();

  for (let i = 0; i < 20; i++) {
    if (visited.has(current))
      return { hops, loop: true };
    visited.add(current);

    const res = await fetch(current, {
      redirect: 'manual',
      method: 'HEAD'
    });
    hops.push({ url: current, status: res.status });

    const location = res.headers.get('location');
    if (!location || ![301,302,303,307,308]
        .includes(res.status)) break;
    current = new URL(location, current).href;
  }
  return { hops, loop: false };
}
              
Tool

Try this concept hands-on with the interactive tool.

100% Free · No signup · No cost

Generate something unguessable right now

148 bits of entropy, a crack-time estimate you can trust, and a clipboard that clears itself after 30 seconds.

Open the toolkit

Part of the Toolly ecosystem · secure.toolly.site