Skip to content

Fuzzy rule canonicalising the SCP wiki's alias hosts #423

Description

@benoit74

Driver: zim-requests#402, the English SCP wiki. Implemented in rules/rules.yaml with tests.

Problem

scp-wiki.wikidot.com (canonical), scpwiki.com, www.scpwiki.com and www.scp-wiki.net all serve the same content, with 200 OK rather than a redirect, and pages link across them freely — SCP-4558's own ListPages pager points at http://www.scp-wiki.net/scp-4558/offset/1.

On a 10-page crawl that cost: 30 escaped links (3 per page) whose target was in the ZIM under the canonical host, and SCP-4558's entire offset chain stored only under alias hosts — 5 entries under scpwiki.com, 5 under www.scp-wiki.net, none canonical. zimcheck independently flagged the duplicated favicon as redundant data.

This is a correctness problem, not a size one: links that should resolve inside the ZIM don't.

Widening the crawl's scope is not the alternative it looks like. These hosts answer 200, so crawling them duplicates every article rather than producing a redirect to follow — and an enumerated crawl driven by a seed list and a restrictive scope regex will not request them at all, leaving the links dangling. A fuzzy rule fixes the paths at conversion time and costs no requests.

Rule

- name: scp_alias_hosts
  pattern: ^(?:www\.)?(?:scpwiki\.com|scp-wiki\.net)/(.*)
  replace: scp-wiki.wikidot.com/\1
  unreplace_pattern: (?!)
  unreplace: ""

Two deliberate choices:

  • Anchored with ^, unlike most rules in this file, because it rewrites the host — and that is not hypothetical. Sibling language branches live on subdomains of these very domains (ko.scp-wiki.net), and an unanchored match would rewrite them onto the English wiki. Tested, along with a lookalike (evil-scpwiki.com).
  • unreplace_pattern is the never-matching (?!). The forward rule cannot know which alias a canonical URL came from, and the overwhelming majority of scp-wiki.wikidot.com URLs were never aliased, so mapping them back would be wrong far more often than right. defuzzify finds no matching unrule and returns its input unchanged — the canonical URL, which is both plausible and correct for the common case. Confirmed in the Python and JS implementations alike; unreplace itself is never applied.

Verification

Rebuilding the same ZIM with the rule: escaped cross-host links 30 → 0, article count unchanged, and no effect on any non-SCP host.

One caveat on the host list, found while re-checking: as of 2026-12-04 only scpwiki.com and the canonical host still answer 200 — www.scpwiki.com and www.scp-wiki.net now 301 to scpwiki.com. The crawl evidence above is from 2026-12-03, so part of the alternation is currently redundant. It is harmless (a rewritten redirect source collapses onto the canonical path, and warc2zim skips the resulting self-redirect) and it guards against the aliases flipping back, which is how they behaved when crawled — but a maintainer may reasonably prefer to narrow it to scpwiki.com.

Activity

  1. self-assigned this
    on Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions