www and non-www versions not resolved to one
What Is This Issue
Websites can typically be accessed with or without the www prefix (e.g., both https://example.com and https://www.example.com). This issue checks whether both hostname variants resolve to a single canonical host through consistent redirects, preventing duplicate content and URL fragmentation.
A passing implementation requires:
- Both
wwwandnon-wwwversions redirect to the same canonical hostname - Consistent redirects for all URLs (not just the homepage)
- No redirect loops between www and non-www variants
- Proper HTTP to HTTPS redirects in addition to www canonicalization
Example: When a user visits https://www.example.com, they are automatically redirected to https://example.com (or vice versa), and this redirect is consistent across all pages.
Why Is This Important
Proper www vs non-www canonicalization is important for SEO because it:
- Prevents Duplicate Content: Search engines might index both versions separately, splitting ranking signals
- Consolidates Link Equity: Inbound links to both versions get consolidated to a single canonical URL
- Improves Crawl Efficiency: Search engines don’t waste crawl budget on duplicate hosts
- Strengthens Rankings: Consolidated signals help improve search rankings for the canonical URL
Without proper canonicalization, search engines may treat www and non-www versions as separate websites, diluting your SEO efforts and potentially causing duplicate content issues.
How XeoPix Detects This
XeoPix performs www vs non-www canonicalization checks through the following logical steps:
-
Hostname Discovery: XeoPix crawls URLs from both the
wwwandnon-wwwversions of your domain to see how they respond. -
Redirect Tracking: For each URL variant, XeoPix follows redirects and records the final destination hostname.
-
Consistency Check: XeoPix verifies that:
- All
wwwURLs redirect to the same canonical hostname - All
non-wwwURLs redirect to the same canonical hostname - The canonical hostname is consistent across all pages (not just the homepage)
- All
-
Loop Detection: XeoPix checks for redirect loops between www and non-www variants.
-
HTTPS Verification: XeoPix ensures that HTTP versions also redirect to HTTPS.
-
Issue Identification: XeoPix raises issues when:
- Both www and non-www versions are accessible without redirecting (CRITICAL)
- Redirects are inconsistent across different pages (WARNING)
- Redirect loops are detected (CRITICAL)
- HTTP doesn’t redirect to HTTPS (WARNING)
- The canonical hostname changes between pages (CRITICAL)
How To Fix
-
Choose your canonical hostname: Decide whether you want your canonical URL to include
wwwor not (e.g.,https://example.comvshttps://www.example.com). -
Configure server-side redirects: Set up 301 redirects at your web server or CDN level to redirect the non-canonical version to the canonical version.
-
Redirect all URLs: Ensure the redirect applies to all pages, not just the homepage (e.g.,
https://www.example.com/productsshould redirect tohttps://example.com/products). -
Handle HTTP to HTTPS: Ensure HTTP versions also redirect to the HTTPS canonical version.
-
Update internal links: Use the canonical hostname consistently in all internal links.
-
Verify with external tools: Use online redirect checkers to confirm the redirects work correctly for various URL paths.
-
Monitor regularly: Periodically check that the canonicalization remains consistent and hasn’t been accidentally broken by server configuration changes.
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 |
|---|---|---|
| originalUrl | String | The original URL that was requested |
| finalUrl | String | The final URL after all redirects |
| 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 (301, 302, 303, 307, 308)
- Redirect Chain — All intermediate URLs and status codes are captured
- Final URL — The destination URL after all redirects are followed
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: Partial Redirects
Problematic State (Fails): Only the homepage redirects, but inner pages don’t:
https://www.example.com→https://example.com(redirects)https://www.example.com/productsreturns 200 OK (no redirect)
Corrected State (Passes): Ensure all pages redirect consistently:
https://www.example.com→https://example.comhttps://www.example.com/products→https://example.com/productshttps://www.example.com/about→https://example.com/about
Example 3: Redirect Loop
Problematic State (Fails): Circular redirects between www and non-www:
https://example.com→https://www.example.comhttps://www.example.com→https://example.com
Corrected State (Passes): Break the loop by redirecting consistently to one canonical version:
https://example.comreturns 200 OK (canonical)https://www.example.com→ 301 redirect →https://example.com
Unit Test
Test File
xeopix-crawling-v2/__tests__/seo-audit-checks/crawlBehaviour/issue-10-www-vs-non.test.js
Purpose
This unit test validates that the checkWwwVsNonRedirect() function correctly determines whether a website properly redirects between www and non-www versions of the domain, ensuring only one canonical version is accessible.
Tested Function
checkWwwVsNonRedirect() from seo-audit-checks.js
Issue Information
- Issue Number: 10
- Issue Code:
WWW_VS_NON - Toggle Group:
crawlBehaviour
Test Scenarios
Positive Test Cases
- The preferred version returns HTTP 200 and the other version redirects with HTTP 301 to the preferred version → no issue,
hasRedirectis true,preferredVersionis set
Negative Test Cases
- Both www and non-www versions resolve without a proper 301 redirect →
WWW_VS_NONissue created with statusmissing-redirectand message containing'both serve content'
Boundary Cases
None
Edge Cases
- Empty input string → no issues created,
preferredVersionis null,hasRedirectis false
Expected Outcome
Pass
A WWW_VS_NON issue is not reported when one version returns 200 and the other version returns 301 redirecting to it.
Fail
A WWW_VS_NON issue is reported with status missing-redirect when both versions return HTTP 200 without redirecting to a canonical hostname.
Validation
- Verifies correct detection of proper www/non-www redirect setup
- Validates issue creation when both versions serve content independently
- Checks return structure (
detectedIssues,hasRedirect,preferredVersion) - Ensures empty input is handled safely without creating false issues
Related Production Files
xeopix-crawling-v2/seo-audit-checks.jsxeopix-crawling-v2/issueCodes.js
Coverage Summary
- 3 test cases (positive, negative, and edge case)
- Covers the primary redirect detection logic
- Validates payload structure and status codes
- Includes empty input safety handling
References
- Consolidate Duplicate URLs — Google Search Central
- 301 Redirects — Google Search Central
- Canonical URLs — Google Search Central