---
title: "Fix your redirect chains, loops, and status codes."
description: "Trace old URLs to their final destination, flatten chains, pick permanent or temporary codes, and test your redirect map in CI."
canonical: "https://scalewithsearch.com/articles/redirect-chains-301-developers"
date: "2026-03-20"
modified: "2026-09-25"
---
## Site navigation

- [Scale With Search](https://scalewithsearch.com/)
- Real estate
  - Real estate
    - [Real estate](https://scalewithsearch.com/for/real-estate)
- Work
  - Start here
    - [Send your brief](https://scalewithsearch.com/work#send-your-brief)
    - [Prepare your six-question brief](https://scalewithsearch.com/work#prepare-your-six-question-brief)
  - Build
    - [Site build, content library with SEO, signal desk](https://scalewithsearch.com/work)
- For your business
  - Trades and home services
    - [Auto body and collision shops](https://scalewithsearch.com/for/auto-body-and-collision-shops)
    - [Foundation and home repair contractors](https://scalewithsearch.com/for/foundation-and-home-repair)
    - [Garage door and fencing contractors](https://scalewithsearch.com/for/garage-door-and-fencing-contractors)
    - [HVAC contractors](https://scalewithsearch.com/for/hvac-contractors)
    - [Janitorial and commercial cleaning companies](https://scalewithsearch.com/for/janitorial-and-commercial-cleaning)
    - [Locksmiths](https://scalewithsearch.com/for/locksmiths)
    - [Moving companies](https://scalewithsearch.com/for/moving-companies)
    - [Pest control companies](https://scalewithsearch.com/for/pest-control-companies)
    - [Plumbing and electrical contractors](https://scalewithsearch.com/for/plumbing-and-electrical-contractors)
    - [Restoration and water or fire damage companies](https://scalewithsearch.com/for/restoration-and-water-fire-damage)
    - [Roofing companies](https://scalewithsearch.com/for/roofing-companies)
    - [Towing companies](https://scalewithsearch.com/for/towing-companies)
    - [Tree services and landscaping companies](https://scalewithsearch.com/for/tree-services-and-landscaping)
    - [Solar installers](https://scalewithsearch.com/for/solar-installation)
    - [General contractors](https://scalewithsearch.com/for/general-contractors-and-construction)
    - [Paving, concrete, and flooring contractors](https://scalewithsearch.com/for/paving)
  - Practices and professional services
    - [Bookkeeping and tax practices](https://scalewithsearch.com/for/bookkeeping-and-tax-practices)
    - [Dental practices](https://scalewithsearch.com/for/dental-practices)
    - [Family and criminal defense law firms](https://scalewithsearch.com/for/family-and-criminal-defense-law-firms)
    - [Med spas and aesthetics practices](https://scalewithsearch.com/for/med-spas-and-aesthetics)
    - [Personal injury law firms](https://scalewithsearch.com/for/personal-injury-law-firms)
    - [Veterinary clinics](https://scalewithsearch.com/for/veterinary-clinics)
    - [Gyms and fitness studios](https://scalewithsearch.com/for/fitness)
    - [Therapy and outpatient health practices](https://scalewithsearch.com/for/therapy-and-outpatient-health)
    - [Medical billing companies](https://scalewithsearch.com/for/medical-billing)
    - [Insurance agencies](https://scalewithsearch.com/for/insurance-agencies)
    - [Financial advisors](https://scalewithsearch.com/for/financial-advisors)
    - [Property management companies](https://scalewithsearch.com/for/property-management)
    - [Recruiting and staffing agencies](https://scalewithsearch.com/for/recruiting-and-staffing)
    - [Architects and interior designers](https://scalewithsearch.com/for/architects-and-interior-designers)
    - [Logistics and supply chain companies](https://scalewithsearch.com/for/logistics-and-supply-chain)
  - Agencies, MSPs, and manufacturing
    - [IT and managed service providers](https://scalewithsearch.com/for/it-and-managed-service-providers)
    - [Machine shops and precision manufacturers](https://scalewithsearch.com/for/machine-shops-and-precision-manufacturing)
    - [Marketing agencies and freelancers](https://scalewithsearch.com/for/marketing-agencies-and-freelancers)
    - [SEO agencies and consultants](https://scalewithsearch.com/for/seo-agencies-and-consultants)
    - [Small manufacturers and fabricators](https://scalewithsearch.com/for/small-manufacturers-and-fabricators)
  - Restaurants, shops, studios, and nonprofits
    - [Restaurants and hospitality businesses](https://scalewithsearch.com/for/restaurants-and-hospitality)
    - [Retail stores and ecommerce sellers](https://scalewithsearch.com/for/retail-and-ecommerce)
    - [Photographers, event planners, and travel agents](https://scalewithsearch.com/for/photographers)
    - [Churches and nonprofits](https://scalewithsearch.com/for/churches-and-nonprofits)
  - [All industries](https://scalewithsearch.com/for/)
- Learn
  - For your office
    - [Office job guides](https://scalewithsearch.com/guides/)
    - [Browser calculators](https://scalewithsearch.com/tools/)
  - Start here
    - [How it works](https://scalewithsearch.com/how-it-works)
    - [Free Starter Kit](https://scalewithsearch.com/kit/business-memory-starter-kit.zip)
    - [Synthetic specimen](https://scalewithsearch.com/specimen/working-session-specimen.zip)
  - Guides
    - [The Complete Guide to Business Memory for AI Agents](https://scalewithsearch.com/articles/business-memory-for-ai-agents-guide)
    - [The Complete Small-Business Guide to AI Agent Governance](https://scalewithsearch.com/articles/ai-agent-governance-guide-small-business)
    - [The Complete Guide to Leaving Vendor AI Memory](https://scalewithsearch.com/articles/leaving-vendor-ai-memory-guide)
  - Articles by cluster
    - [Business memory](https://scalewithsearch.com/articles/business-memory-for-ai-agents-guide)
    - [Agent governance](https://scalewithsearch.com/articles/ai-agent-governance-guide-small-business)
    - [Migration and ownership](https://scalewithsearch.com/articles/leaving-vendor-ai-memory-guide)
  - For machines
    - [llms.txt](https://scalewithsearch.com/llms.txt)
    - [llms-full.txt](https://scalewithsearch.com/llms-full.txt)
    - [Machine view](https://scalewithsearch.com/?view=machine)
- Company
  - Evidence
    - [Proof](https://scalewithsearch.com/proof)
  - Company
    - [About](https://scalewithsearch.com/about)

# Flatten redirect chains and choose the right status code for every URL move.

A site moved to HTTPS in 2019, dropped `www` in 2021, and restructured its URLs in 2024. Each project added its own redirects. Today a link to an old product page passes through three hops before it loads. Some old URLs loop between the CDN and the origin.

Many developers treat redirects as simple path maps: old URL points to new URL, job done. That view misses four SEO effects. Chains grow to three or four hops. Temporary redirects stay in place of permanent ones. Loops trap crawlers, and meta refresh redirects slow users.

Each hop adds latency, often 100 to 300 ms. Each hop also adds a chance that a crawler stops before the destination. During a migration, a restructure, or a merger, careless redirects can depress rankings for months while search engines consolidate signals.

This guide covers the redirect types and how to find and fix chains and loops. It also covers audit tools for large sites and patterns that stop redirect debt from growing.

## Choose the right redirect type

| Type | Meaning | SEO effect | Use for |
|---|---|---|---|
| 301 Moved Permanently | The URL moved for good | A strong signal that the target should be canonical; Google moves ranking signals to it and drops the old URL over time | Permanent moves, domain migrations, URL structure changes |
| 302 Found | The move is temporary | A weak canonical signal; Google usually keeps the original URL indexed | A/B tests, seasonal promotions, short maintenance pages |
| 307 Temporary Redirect | Temporary, and the method must not change | Same as 302 | Temporary moves where a POST must stay a POST |
| 308 Permanent Redirect | Permanent, and the method must not change | Same as 301 | Permanent moves for APIs and forms; all current browsers support it |
| Meta refresh | An HTML tag redirects after a delay | Google treats an instant refresh as permanent and a delayed one as temporary; slower for users | Only when you cannot send a server redirect |
| JavaScript redirect | `window.location` changes the page | Google follows it after rendering, with delay and less reliability | Only when server redirects are impossible, such as client-side routing in a single-page app |

Google representatives stated in 2016 that 3xx redirects do not lose PageRank. That applies to one clean hop. Chains still cost time, crawl effort, and reliability.

### Stop the 302 habit

Many developers default to 302 as the reversible choice. Search engines read it literally: the old URL stays canonical, and the new URL does not collect authority. Six months after a redesign, old URLs still rank, new ones struggle, and traffic splits between them.

Use 301 for permanent changes. If you are unsure whether a move is permanent, start with 302. Watch for four to eight weeks, then switch to 301. Google can treat a long-lived 302 as permanent, but do not rely on it. A long 302 delays consolidation.

## Understand why chains hurt

A chain forms when URL A redirects to B, B to C, and so on. Each hop adds five kinds of cost:

- **Latency.** Each hop is another round trip. A three-hop chain can add 300 to 900 ms before content starts to load, and mobile users on slow connections can wait seconds.
- **Crawl effort.** Googlebot follows each hop, which uses crawl capacity that could reach real pages. Googlebot follows up to 10 hops; past that, Search Console reports a redirect error.
- **Signal loss in practice.** Each extra hop is a place for a misconfiguration, and discovery takes longer. A link to A that reaches D through B and C is less reliable than a direct link to D.
- **Failure risk.** Each hop can time out, break, or go offline. Longer chains break more often.
- **Analytics gaps.** Referrer data can drop along the way, which splits attribution across URLs.

### Know how chains form

- **Stacked migrations.** HTTP to HTTPS adds one redirect, `www` to non-`www` adds another, and a URL restructure adds a third. Nobody flattens them.
- **Repeated URL changes.** Marketing changes a pattern, product refines it, and engineering changes it again. Each change adds a hop instead of updating the old rules.
- **Platform moves.** A site moves from WordPress to Shopify to a custom platform, and each move keeps the previous redirects. Some URLs end up with four or five hops.
- **Domain consolidation.** Acquired domains redirect to old main-site URLs, which later redirect to new main-site URLs.

## Find chains

**Command line.** Trace one URL with `curl`:

```bash
curl -I https://example.com/old-page
```

Each `301` or `302` response is one hop. Add `-L` to follow the whole chain.

**Browser tools.** The Network panel in browser developer tools shows each redirect response in order.

**Screaming Frog SEO Spider.** Crawl the site and open the redirect chains report. It lists hop counts and final destinations.

**Google Search Console.** The Page indexing report lists "Page with redirect" and "Redirect error" URLs. URL Inspection shows how Google resolved a specific URL.

**Ahrefs Site Audit or Semrush Site Audit.** Both report chains with hop counts and flag long chains as priority issues.

**A script for scale.** This Python function follows each hop without letting the library auto-follow, and resolves relative `Location` headers:

```python
import requests
from urllib.parse import urljoin

def trace_redirects(url, max_hops=10):
    hops = []
    for _ in range(max_hops):
        response = requests.head(url, allow_redirects=False, timeout=10)
        hops.append((url, response.status_code))
        if response.status_code not in (301, 302, 303, 307, 308):
            break
        location = response.headers.get('Location')
        if not location:
            break
        url = urljoin(url, location)
    return hops

print(trace_redirects('https://example.com/old-url'))
```

Some servers answer `HEAD` differently from `GET`. If results look wrong, switch to `requests.get` with `stream=True`. Server logs show which redirects Googlebot actually hits; the [log file analysis guide](/articles/log-file-analysis-seo) shows how to count them.

## Fix chains

**Flatten.** Point every redirect straight at the final destination. Replace A to B to C with A to C.

Before:

```text
http://example.com/page -> https://example.com/page -> https://example.com/new-page
```

After:

```text
http://example.com/page -> https://example.com/new-page
```

**Keep one redirect map.** Store every source and destination in one place: a CSV file, a database table, or a configuration file. When URLs change again, update the old entries to point at the new final URLs, not at intermediate ones.

**Test in CI.** Before each deployment, a script should confirm four things:

- no redirect has more than one hop;
- each redirect uses the right status code;
- no loops exist;
- every target returns 200, not 404 or 500.

The [SEO testing guide for CI/CD pipelines](/articles/seo-testing-ci-cd-pipeline) shows where these checks run.

**Use a redirect manager.** On WordPress, the Redirection plugin and the redirect manager in Yoast SEO Premium track redirects and detect chains. Enterprise platforms often include redirect management.

**Start with the URLs that matter.** With limited time, fix chains first on:

- pages with more than about 100 visits a month;
- pages with backlinks from 10 or more referring domains;
- conversion pages, such as products, pricing, and contact.

Low-traffic pages without links can wait.

## Prevent redirect loops

A loop forms when A redirects to B and B leads back to A, directly or through other URLs. Browsers and crawlers stop at their limit and show "Too many redirects".

Common causes:

- conflicting rules in `.htaccess`, `nginx.conf`, or application code;
- an HTTP-to-HTTPS rule that fights an HTTPS misconfiguration sending traffic back to HTTP;
- the same conflict between `www` and non-`www`;
- CDN rules that contradict origin server rules.

You find loops through browser errors, crawler reports such as Screaming Frog's, or `curl -L` failing at its redirect limit.

To prevent them, test every redirect right after you add it, and validate the rules in staging first. Document each rule so later changes do not conflict with it. Keep rules simple, because complex rules create circular logic more often.

To resolve a loop, find the pair of rules that redirect to each other. Remove or narrow one of them. Then test every variation: HTTP and HTTPS, `www` and non-`www`, with and without a trailing slash.

## Manage redirects as code

**One home for all rules.** Keep redirects in one place, not spread across `.htaccess` files, application code, and CDN settings.

**A redirect layer.** Route all requests through one redirect handler. It gives you consistent status codes, central logs of which redirects get traffic, rule changes without an application deployment, and automatic chain flattening in middleware.

**Version control.** Keep redirect maps in Git. You get history, rollback, and review before changes ship.

**Expiry for temporary redirects.** Give every 302 an end date. At that date, convert it to a 301 or remove it, so "temporary" redirects do not live for years.

**Canonical routing in the application.** Enforce the canonical form of each URL in routing logic, so a non-canonical variation redirects once, before other rules run. The [canonical tags guide for developers](/articles/canonical-tags-developers) covers how redirects and canonical tags work together.

**Pattern rules for large moves.** Use one pattern instead of thousands of single mappings. In nginx, a named capture keeps the rest of the path:

```nginx
location ~ ^/old-category/(?<rest>.*)$ {
    return 301 /new-category/$rest;
}
```

This sends every URL under `/old-category/` to the same path under `/new-category/`. In Apache, `RedirectMatch 301` with a numbered back-reference does the same job.

## Handle domain-level redirects

**Domain consolidation.** When you merge domains, redirect at the server level. Cover every subdomain and URL variation, not only the pages you remember.

**Cross-domain moves.** Send each old URL directly to its final URL on the new domain with one 301. Do not route through intermediate domains or subdomains.

**HTTPS.** Redirect HTTP to HTTPS in the server configuration. Add HSTS so browsers use HTTPS without a redirect after the first visit:

```apache
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
```

**`www` or not.** Choose one host and redirect the other:

```nginx
server {
    server_name www.example.com;
    return 301 https://example.com$request_uri;
}
```

**Trailing slashes.** Pick `/page/` or `/page`, and redirect the other form to it.

## Make redirects fast

**Redirect at the edge.** Cloudflare, Fastly, and Amazon CloudFront can answer redirects from edge locations, which is faster than a round trip to the origin. The [edge SEO guide](/articles/edge-seo-cdn-workers) covers redirects in CDN workers.

**Know how browsers cache.** Browsers cache 301 responses by default, often with no expiry. Returning visitors skip the extra request, but a wrong 301 is hard to undo in their browsers. Test before you ship. For 302 responses, set an explicit `Cache-Control` header if you want them cached.

**Plan final URLs first.** In a migration, map each old URL to its final new URL from the start. Do not ship an interim structure that will need its own redirects later.

**Watch latency.** Track redirect response times in server logs or your application performance monitoring tool. Slow redirects point to server load or rule logic that needs work.

## Set hop limits, removal rules, and retention

**Hop limit.** Zero hops is ideal, and one is the working maximum. Googlebot follows up to 10, but every extra hop adds cost and risk.

**Missing pages.** If the content is gone and has no close successor, return 404 or 410. If equivalent content exists, redirect to it with a 301. Do not redirect every missing page to the homepage. Google treats those redirects as soft 404s, and users land somewhere they did not expect. The [HTTP status codes guide](/articles/http-status-codes-seo) covers each response.

**Retention after a migration.** Keep redirects for important pages indefinitely, because links and bookmarks last for years. Google's site move guidance says to keep redirects for at least one year. For low-value pages with no traffic or links after 12 to 24 months, you can retire them.

----

```text
                  .|########||.                                       .|########||.                                       .|########||.
               |##||.      .||##|.                                 |##||.      .||##|.                                 |##||.      .||##|.
             |#|.              .|#|.                             |#|.              .|#|.                             |#|.              .|#|.
           |#|                    |#|                          |#|                    |#|                          |#|                    |#|
         .#|                        |#.                      .#|                        |#.                      .#|                        |#.
        .#.                          .#|                    .#.                          .#|                    .#.                          .#|
       |#.                            .#|                  |#.                            .#|                  |#.                            .#|
      |#             ......             #|                |#             ......             #|                |#             ......             #|
     .#           ||#########|           #|              .#           ||#########|           #|              .#           ||#########|           #|
    .#.         |######||######|.        .#.            .#.         |######||######|.        .#.            .#.         |######||######|.        .#.
    #.        .##|###|##|#|######|        .#            #.        .##|###|##|#|######|        .#            #.        .##|###|##|#|######|        .#
   ||        |##|#||||||||||||#||#|        ||          ||        |##|#||||||||||||#||#|        ||          ||        |##|#||||||||||||#||#|        ||
   #        |#||||||||||||||||||||#|        #.         #        |#||||||||||||||||||||#|        #.         #        |#||||||||||||||||||||#|        #.
  ||       |#||||||||||||||||||||||#|       ||        ||       |#||||||||||||||||||||||#|       ||        ||       |#||||||||||||||||||||||#|       ||
  #       .#||||||||||||||||||||||||#|       #        #       .#||||||||||||||||||||||||#|       #        #       .#||||||||||||||||||||||||#|       #
 ||   ....|||#||||||##|#|||#|#||##||||....|. ||      ||   ....|||#||||||##|#|||#|#||##||||....|. ||      ||   ....|||#||||||##|#|||#|#||##||||....|. ||
 #.  .  ....|#  ....#|||   ||| .#|||  ....#. .#      #.  .  ....|#  ....#|||   ||| .#|||  ....#. .#      #.  .  ....|#  ....#|||   ||| .#|||  ....#. .#
 #   .  ||||#| .#####||  . .#| .#|||  ||||#   #.     #   .  ||||#| .#####||  . .#| .#|||  ||||#   #.     #   .  ||||#| .#####||  . .#| .#|||  ||||#   #.
.|   |||||  #. |#|||||. ||  #. |#||. .|||||   ||    .|   |||||  #. |#|||||. ||  #. |#||. .|||||   ||    .|   |||||  #. |#|||||. ||  #. |#||. .|||||   ||
||   |....  #. ....|#.      |. ...|. ....||   ||    ||   |....  #. ....|#.      |. ...|. ....||   ||    ||   |....  #. ....|#.      |. ...|. ....||   ||
#.  .||||||##||||||##||####|||||||#||||||#|   .#    #.  .||||||##||||||##||####|||||||#||||||#|   .#    #.  .||||||##||||||##||####|||||||#||||||#|   .#
#    .||####|###########################|.     #    #    .||####|###########################|.     #    #    .||####|###########################|.     #
#      .#||||||.#.|| # |. ..# #| #|||||#|      #    #      .#||||||.#.|| # |. ..# #| #|||||#|      #    #      .#||||||.#.|| # |. ..# #| #|||||#|      #
#      .#|||||| ..  |# ## |#| ...#|#|||#|      #    #      .#|||||| ..  |# ## |#| ...#|#|||#|      #    #      .#|||||| ..  |# ## |#| ...#|#|||#|      #
#      .#|||#|# .# .#| #| ##|.#..#|||||#|      #    #      .#|||#|# .# .#| #| ##|.#..#|||||#|      #    #      .#|||#|# .# .#| #| ##|.#..#|||||#|      #
#      .#||||||############|######|||||#|      #    #      .#||||||############|######|||||#|      #    #      .#||||||############|######|||||#|      #
#   |...||#||||||#||||#|#||||||#|||||#||| |.|  #    #   |...||#||||||#||||#|#||||||#|||||#||| |.|  #    #   |...||#||||||#||||#|#||||||#|||||#||| |.|  #
#. .. ||||# .|||##|.  |#| .|| || .|||#. #|  # .#    #. .. ||||# .|||##|.  |#| .|| || .|||#. #|  # .#    #. .. ||||# .|||##|.  |#| .|| || .|||#. #|  # .#
|| |  ...||  ...##| |  #| .|. |. #####  .. .| ||    || |  ...||  ...##| |  #| .|. |. #####  .. .| ||    || |  ...||  ...##| |  #| .|. |. #####  .. .| ||
|| ||||| || ||||#|  .  |. |. |#. ||||| |#| || ||    || ||||| || ||||#|  .  |. |. |#. ||||| |#| || ||    || ||||| || ||||#|  .  |. |. |#. ||||| |#| || ||
.# |.....#|....|#.||||.|||##.|#|....||.#||.#. #.    .# |.....#|....|#.||||.|||##.|#|....||.#||.#. #.    .# |.....#|....|#.||||.|||##.|#|....||.#||.#. #.
 #.|||||||#############################| ||| .#      #.|||||||#############################| ||| .#      #.|||||||#############################| ||| .#
 ||       ##||#||#||||||#||#||#||#||##.      ||      ||       ##||#||#||||||#||#||#||#||##.      ||      ||       ##||#||#||||||#||#||#||#||##.      ||
  #       .#|||||||||#||#|||||||||||#|       #        #       .#|||||||||#||#|||||||||||#|       #        #       .#|||||||||#||#|||||||||||#|       #
  ||       |#||||||||||||||||||||||#|       ||        ||       |#||||||||||||||||||||||#|       ||        ||       |#||||||||||||||||||||||#|       ||
  .#        |#||||||||||||||||||||#|        #.        .#        |#||||||||||||||||||||#|        #.        .#        |#||||||||||||||||||||#|        #.
   ||        |#||||||||||||||||||#|        ||          ||        |#||||||||||||||||||#|        ||          ||        |#||||||||||||||||||#|        ||
    #.        .######|#|#########|        .#            #.        .######|#|#########|        .#            #.        .######|#|#########|        .#
    .#.         |#####||||#####|         .#.            .#.         |#####||||#####|         .#.            .#.         |#####||||#####|         .#.
     |#           ||########||           #.              |#           ||########||           #.              |#           ||########||           #.
      |#             ......             #|                |#             ......             #|                |#             ......             #|
       |#.                            .#|                  |#.                            .#|                  |#.                            .#|
        |#.                          .#.                    |#.                          .#.                    |#.                          .#.
         .#|                        |#.                      .#|                        |#.                      .#|                        |#.
           |#|                    |#|                          |#|                    |#|                          |#|                    |#|
            .|#|.              .|#|.                            .|#|.              .|#|.                            .|#|.              .|#|.
               |##||.      .||##|                                  |##||.      .||##|                                  |##||.      .||##|
                 .||########||.                                      .||########||.                                      .||########||.

Scale With Search  2026  [scalewithsearch.com](https://scalewithsearch.com)
```
