Skip to Content

Redirect chains and loops

What Is This Issue

This issue checks whether a website consistently redirects between the www and non-www versions of the domain, ensuring only one version is accessible.

A passing implementation means:

  • Either the www version (https://www.example.com ) OR the non-www version (https://example.com ) is the canonical version
  • The non-preferred version automatically redirects to the preferred version using 301 redirects
  • All variations (http/https, www/non-www) ultimately resolve to the same canonical URL

Example: If the preferred version is non-www, then:

  • http://example.comhttps://example.com
  • http://www.example.comhttps://example.com
  • https://www.example.comhttps://example.com

Why Is This Important

Duplicate Content: Search engines may index both www and non-www versions as separate pages, splitting ranking signals and causing duplicate content issues.

Crawl Budget: Crawling both versions wastes crawl budget on duplicate pages instead of discovering new content.

Link Equity: Backlinks pointing to both versions dilute the page’s authority instead of consolidating it to a single URL.

Rankings: Inconsistent redirects confuse search engines about which URL is the canonical version, potentially hurting rankings.

SEO Health Score: Resolving this issue improves the technical SEO score by eliminating duplicate content risks and consolidating ranking signals.

How XeoPix Detects This

XeoPix performs the following checks:

  1. Crawls both versions - The crawler attempts to access both the www and non-www versions of the domain.

  2. Checks redirect behavior - For each version, XeoPix follows the redirect chain and records the final destination URL.

  3. Validates consistency - The system checks whether all variations (http/https, www/non-www) consistently redirect to a single canonical version.

  4. Identifies redirect type - XeoPix verifies that 301 (permanent) redirects are used, not 302 (temporary) redirects.

  5. Reports issues - If both versions are accessible without redirecting to a single canonical URL, or if redirects are inconsistent, the issue is flagged.

How To Fix

  1. Choose your preferred domain format - Decide whether to use www or non-www (consider existing backlinks and brand consistency).

  2. Configure server-side redirects - Set up 301 redirects from the non-preferred version to the preferred version at the server level (Apache, Nginx, Cloudflare, etc.).

  3. Redirect all variations - Ensure all four combinations redirect properly:

  4. Update Google Search Console - Add both versions (www and non-www) and set the preferred domain in GSC settings.

  5. Update internal links - Ensure all internal links use the canonical version consistently.

  6. Update XML sitemap - Only include the preferred version URLs in your sitemap.

What We Store

Storage Level

Page Level — This issue is evaluated for each individual URL that returns a redirect.


Database Table / Prisma Model

RedirectChain


Stored Fields

FieldTypeDescription
chainJsonArray of all redirect hops (URLs and status codes)
chainLengthIntNumber of redirects in the chain
hasLoopBooleanWhether the redirect chain contains a loop

Detection Dependencies

  • The following data sources are required to evaluate this issue:
  • HTTP Response — The crawler follows redirect responses and captures the full chain
  • Redirect Chain — The complete chain of redirects is analyzed for length and loops

Examples

Example 1: Inconsistent WWW vs Non-WWW

Problematic State (Fails): Both versions are accessible without redirecting:

  • https://example.com returns 200 OK
  • https://www.example.com returns 200 OK

Search engines may index both as separate pages.

Corrected State (Passes): Choose one canonical version and redirect the other:

  • https://www.example.com → 301 redirect → https://example.com
  • https://example.com returns 200 OK (canonical)

Example 2: Missing HTTP to HTTPS Redirect

Problematic State (Fails): HTTPS redirects properly, but HTTP doesn’t:

  • http://example.com returns 200 OK (no redirect)
  • https://www.example.comhttps://example.com (redirects)

Corrected State (Passes): Ensure all HTTP versions redirect to HTTPS:

  • http://example.com → 301 redirect → https://example.com
  • http://www.example.com → 301 redirect → https://example.com
  • https://www.example.com → 301 redirect → https://example.com

Example 3: Using 302 Instead of 301

Problematic State (Fails): Using temporary (302) redirects instead of permanent (301):

  • https://www.example.com → 302 redirect → https://example.com

Corrected State (Passes): Use 301 permanent redirects:

  • https://www.example.com → 301 redirect → https://example.com

Unit Test

Test File

xeopix-crawling-v2/__tests__/seo-audit-checks/crawlBehaviour/issue-11-no-redirect-chains.test.js

Purpose

This unit test validates that the analyzeRedirectChain() function correctly identifies redirect chains, detects loops, and reports chain length information.

Tested Function

analyzeRedirectChain() from utils/redirects.js

Issue Information

  • Issue Number: 11
  • Issue Code: NO_REDIRECT_CHAINS
  • Toggle Group: crawlBehaviour

Test Scenarios

Positive Test Cases

  • Simple redirect chain (2 hops: 301 → 200) → hasLoop is false, chainLength is 2

Negative Test Cases

  • Redirect loop detected (URL repeats in the chain: A → B → A) → hasLoop is true, chainLength is 3

Boundary Cases

None

Edge Cases

  • Empty redirect chain (no entries) → hasLoop is false, chainLength is 0

Expected Outcome

Pass

A NO_REDIRECT_CHAINS issue is not reported when the redirect chain has no loops and has a reasonable length.

Fail

A NO_REDIRECT_CHAINS issue is reported when:

  • A redirect loop is detected (a URL appears more than once in the chain)

Validation

  • Verifies correct chain length calculation for simple redirects
  • Validates loop detection when a URL repeats in the chain
  • Checks safe handling of empty redirect data
  • xeopix-crawling-v2/utils/redirects.js
  • xeopix-crawling-v2/issueCodes.js

Coverage Summary

  • 3 test cases (positive, negative, and edge case)
  • Covers basic redirect chain analysis and loop detection
  • Validates return structure (hasLoop, chainLength)
  • Includes empty input safety handling

References

Last updated on