A page that redirects several times before it loads can feel slow, frustrate visitors, and make it harder to diagnose which URL is actually canonical. The cause is often a sequence of individually valid rules—such as HTTP-to-HTTPS, non-www-to-www, and a legacy URL migration—that have not been combined into a direct path. This guide explains how to find redirect chains and loops, how to fix them safely, and how to check that the final destination is the one you intend.
Key takeaways
- A redirect chain is a series of URL changes before the browser reaches a final response.
- A redirect loop occurs when rules send a request back to a URL it has already visited, preventing it from reaching a usable destination.
- Trace each hop, then update the rule that creates the unnecessary detour so the original URL redirects directly to the final destination.
- Check both server responses and application behavior. A URL inspection tool can show redirect hops, but it cannot change server-side rules or prove that every visitor receives the same response.
- Retest important URLs after changes, including variations for HTTP or HTTPS, hostnames, paths, and query strings.
What is a redirect chain?
A redirect chain is a sequence of HTTP responses that point a requester from one URL to another. For example:
http://example.com/old-page
→ https://example.com/old-page
→ https://www.example.com/old-page
→ https://www.example.com/new-page
Each arrow represents another request and response. The browser cannot request the next URL until it has received the preceding redirect, so extra hops can add delay. The effect depends on the network, server response time, caching, and the visitor's connection; there is no single delay that applies to every chain.
Redirects are not inherently a problem. They are useful when a URL has moved, a site changes its preferred hostname, or an HTTP URL needs to lead to its HTTPS equivalent. The trouble is usually a chain that could be shortened, a rule that sends visitors to the wrong destination, or a loop that prevents loading altogether.
Redirect chains and HTTP status codes
Common redirect status codes include:
| Status | General meaning | Typical use |
|---|---|---|
| 301 Moved Permanently | The resource has moved permanently. | A lasting URL migration or canonicalization rule. |
| 302 Found | A temporary redirect. | A temporary move where the original URL may be used again. |
| 303 See Other | Directs the requester to another resource, commonly after a form submission. | Post/Redirect/Get workflows. |
| 307 Temporary Redirect | A temporary redirect that preserves the request method. | A temporary move where method preservation matters. |
| 308 Permanent Redirect | A permanent redirect that preserves the request method. | A lasting move where method preservation matters. |
The status code affects how clients interpret the redirect, including whether the original request method is preserved. Choose a code based on the intended behavior; do not treat these codes as interchangeable. Search engines also consider redirects when processing URL changes, but a redirect alone does not guarantee a particular indexing or ranking outcome.
Advertisement 5349509459
Why a website redirects multiple times
The most common cause is overlapping canonicalization rules. Different layers of a site may each make a valid change, but in the wrong order or without accounting for the next layer.
For example, a hosting platform might redirect HTTP to HTTPS, a web server might redirect the bare domain to www, and the application might redirect an old path to a new one. If each rule only knows about one change, a visitor can pass through several intermediate URLs.
Other common causes include:
- A URL migration was applied in stages. An old URL points to an intermediate URL that later moved again.
- Rules differ between layers. A CDN, reverse proxy, web server, and application can all issue redirects.
- Trailing-slash or case rules conflict. One rule adds a slash while another removes it, or one layer changes path capitalization while another changes it back.
- The application misidentifies the request scheme. Behind a proxy or load balancer, the app may think an HTTPS request is HTTP and redirect repeatedly. Configure forwarded-protocol handling only for trusted proxies.
- Cached redirects obscure a recent fix. Browser, proxy, or CDN caches may continue to serve an earlier redirect response.
- A redirect depends on cookies, location, or authentication state. Different requests may follow different paths, making a single test incomplete.
How to find every redirect hop
Start with the exact URL that exhibits the problem, including its scheme, hostname, path, and relevant query string. A redirect checker can help show the response sequence for a URL. Compare its result with a browser and with a command-line request where possible, since tools may differ in headers, cookies, request method, or network location.
With curl, follow redirects and print the response headers for each hop:
curl -sS -L --max-redirs 10 -D - -o /dev/null \
'http://example.com/old-page'
The -L option follows redirects, -D - writes response headers to standard output, and --max-redirs limits how many hops curl will follow. Look for each Location header and status code, then write down the full sequence. Do not assume a HEAD request will behave exactly like a normal browser GET; some applications handle methods differently.
For a quick summary of the final URL, final status, and number of redirects:
curl -sS -L --max-redirs 10 -o /dev/null \
-w 'Final URL: %{url_effective}\nRedirects: %{num_redirects}\nStatus: %{http_code}\n' \
'http://example.com/old-page'
In a browser, open Developer Tools, select the Network panel, enable Preserve log, and load the original URL. Inspect the document requests and their status codes, then check each Location response header. This can reveal behavior that a basic external check misses, such as redirects triggered after a cookie is set.
A URL parser can help inspect components such as the scheme, host, path, and query string. It does not show what a server will return, and parsing a URL is not a substitute for testing the actual HTTP response.
How to fix redirect chains
1. Identify the intended final URL
Choose the destination that should load for the original URL. Confirm its spelling, hostname, scheme, path, and trailing-slash convention. Check that it returns the expected content rather than redirecting again or showing an error.
2. Map the rules responsible for each hop
For every response in the chain, identify which layer issued it: CDN, hosting platform, web server, application, or another proxy. Check configuration and deployment history rather than changing rules blindly. If you remove a rule without understanding its purpose, you could affect other URLs or create a new loop.
3. Redirect the original URL directly to the final destination
Where appropriate, replace a path like A → B → C with A → C. Update other relevant old URLs to point directly to their final destinations too. Preserve query parameters when they are needed for the destination, and verify how your server handles fragments: URL fragments are not sent in HTTP requests, so servers cannot use them to choose a redirect target.
4. Consolidate canonicalization rules carefully
Decide on one preferred scheme, hostname, and path format, then implement a consistent policy. For example, the site might use HTTPS, the www hostname, and no trailing slash for a particular path style. Avoid maintaining competing rules at multiple layers unless the precedence and behavior are clear.
5. Update links and site references
Change internal links, navigation, canonical references, and sitemap entries to use the final URLs where appropriate. A redirect may remain necessary for visitors and external links to older URLs, but internal links should not repeatedly send users through redirects.
Advertisement 8972488872
6. Retest the complete set of URL variants
Test the original URL, each intermediate URL, and the final URL. Also test relevant combinations such as HTTP versus HTTPS, www versus non-www, trailing slash variants, and case variants if your site treats them differently. Check both expected redirect behavior and the final page content. If a CDN is involved, verify the result after any necessary cache invalidation.
How to diagnose a redirect loop
A redirect loop occurs when the sequence returns to a previously visited URL instead of ending at a response the browser can display. For example:
https://example.com/page
→ http://example.com/page
→ https://example.com/page
Look at the repeated URLs and compare the conditions that trigger each redirect. A loop between HTTP and HTTPS can indicate that the proxy terminates HTTPS but the application does not receive or trust the correct forwarded-protocol information. A loop between hostnames or slash variants often points to conflicting rules. A loop that only happens after login may involve cookies, authentication callbacks, or a destination that redirects back to the login page.
Fix the rule at the layer that has incorrect information or conflicting behavior. Do not solve a loop by disabling all redirects: that can expose duplicate URLs or undo intended security and canonicalization behavior. After the change, test from the same network path and with the same relevant cookies or headers as the affected request.
Common mistakes
- Treating every redirect as a defect. A deliberate redirect from a retired URL can be appropriate; the goal is correct, direct behavior.
- Changing a permanent redirect to temporary without a reason. Choose status codes based on whether the move is temporary or permanent and whether method preservation matters.
- Redirecting every removed page to the homepage. Send a URL to its relevant replacement when one exists. A generic destination may confuse visitors and search engines.
- Testing only the final URL. The final page may work even while the original URL still has unnecessary hops or a loop under some conditions.
- Using only one test method. A tool, curl, and a browser may send different requests or reach different infrastructure. Compare the response details.
- Ignoring query strings and request methods. Some rules alter parameters or behave differently for
GETandPOST. Test the cases your site actually supports. - Removing redirects without checking external dependencies. Old URLs may still be used in bookmarks, email, or links from other sites.
Recommended maintenance workflow
Keep a record of URL migrations and their intended destinations. When changing a URL, update internal references and create a direct redirect from the old URL to the final destination. During deployment, test a small set of representative URLs and any high-priority legacy paths. Afterward, monitor server or CDN logs for unexpected redirect volume, repeated requests, and errors.
For security-sensitive systems, treat redirect destinations as a separate concern from URL parsing. If an application accepts user-provided destinations, apply a carefully designed allowlist and server-side controls; a simple hostname check or URL parser is not a complete defense against unsafe redirects or server-side request forgery.
Conclusion
Multiple redirects usually point to overlapping rules, an outdated migration path, or a mismatch between infrastructure and application settings. Trace the response sequence, identify the layer responsible for each hop, and make the original URL lead directly to the intended destination. Then retest URL variants, methods, and relevant browser conditions to confirm that the fix works without creating a loop or breaking legitimate redirects.
