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.com→https://example.comhttp://www.example.com→https://example.comhttps://www.example.com→https://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:
-
Crawls both versions - The crawler attempts to access both the www and non-www versions of the domain.
-
Checks redirect behavior - For each version, XeoPix follows the redirect chain and records the final destination URL.
-
Validates consistency - The system checks whether all variations (http/https, www/non-www) consistently redirect to a single canonical version.
-
Identifies redirect type - XeoPix verifies that 301 (permanent) redirects are used, not 302 (temporary) redirects.
-
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
-
Choose your preferred domain format - Decide whether to use www or non-www (consider existing backlinks and brand consistency).
-
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.).
-
Redirect all variations - Ensure all four combinations redirect properly:
-
Update Google Search Console - Add both versions (www and non-www) and set the preferred domain in GSC settings.
-
Update internal links - Ensure all internal links use the canonical version consistently.
-
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
| Field | Type | Description |
|---|---|---|
| chain | Json | Array of all redirect hops (URLs and status codes) |
| chainLength | Int | Number of redirects in the chain |
| hasLoop | Boolean | Whether 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.comreturns 200 OKhttps://www.example.comreturns 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.comhttps://example.comreturns 200 OK (canonical)
Example 2: Missing HTTP to HTTPS Redirect
Problematic State (Fails): HTTPS redirects properly, but HTTP doesn’t:
http://example.comreturns 200 OK (no redirect)https://www.example.com→https://example.com(redirects)
Corrected State (Passes): Ensure all HTTP versions redirect to HTTPS:
http://example.com→ 301 redirect →https://example.comhttp://www.example.com→ 301 redirect →https://example.comhttps://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) →
hasLoopis false,chainLengthis 2
Negative Test Cases
- Redirect loop detected (URL repeats in the chain: A → B → A) →
hasLoopis true,chainLengthis 3
Boundary Cases
None
Edge Cases
- Empty redirect chain (no entries) →
hasLoopis false,chainLengthis 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
Related Production Files
xeopix-crawling-v2/utils/redirects.jsxeopix-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
- Consolidate Duplicate URLs — Google Search Central
- Canonicalization — Moz