Skip to content

Redirect unknown pages home with a 301 - #32

Merged
lbesecker195 merged 1 commit into
mainfrom
seo/redirect-unknown-pages
Sep 19, 2026
Merged

lbesecker195 merged 1 commit into
mainfrom
seo/redirect-unknown-pages

Conversation

@lbesecker195

Copy link
Copy Markdown
Owner

Closes #31.

A mistyped URL or a delisted server used to render a 404. Both now resolve to the home page with a permanent redirect.

  • Catch-all GET route 301s any unmatched browser path to the home page
  • A plug checks the listing exists ahead of the LiveView, because a LiveView redirecting from mount/3 answers the initial request with a 302 and this had to be a 301
  • That check selects a constant rather than loading the row, whose article_content and tools columns are large
  • The JSON API still answers 404 — a client following a redirect into HTML gets a parse error instead of a clear miss
  • POST is deliberately untouched: a stray POST is not a mistyped URL, and redirecting it would silently drop the body

Verified against the running app:

URL Before After
/servers/io.github.nobody/nothing 404 301 → /
/totally-made-up 404 301 → /
/a/deep/missing/path 404 301 → /
/servers/com.brave/brave-search 200 200
/servers, / 200 200
/api/v0/nope 404 404

71 tests pass.

One caveat worth recording: search engines treat a blanket redirect of every missing URL to the home page as a soft 404, so these URLs are unlikely to pass link value, and Google may report them as such in Search Console. A targeted redirect per retired URL preserves more. Flagging it as a known tradeoff, not a blocker.


Pages affected:

🤖 Generated with Claude Code

A mistyped URL or a delisted server used to render a 404. Both now resolve to
the home page with a permanent redirect, so a visitor who follows a stale link
lands somewhere useful instead of a dead end.

- Add a catch-all GET route that 301s any unmatched browser path to the home page
- Check the listing exists in a plug, ahead of the LiveView, because a LiveView
  redirecting from mount answers with a 302 and this had to be a 301
- Select a constant for that check rather than loading the row, whose article
  and tool columns are large
- Keep the JSON API answering 404, since a client following a redirect into
  HTML gets a parse error instead of a clear miss
- Leave POST alone: a stray POST is not a mistyped URL, and redirecting it
  would silently drop the body

Verified against the running app: unknown paths and missing listings return
301 to /, while real listings, the catalogue and the API are untouched.

---

Pages affected:

- [MCP Registry](https://ai.mcpharbor.dev/) — where every unmatched URL now lands.
- [Browse MCP servers](https://ai.mcpharbor.dev/servers) — the searchable catalogue, still served directly.
- [Brave Search MCP](https://ai.mcpharbor.dev/servers/com.brave/brave-search) — an existing listing, unaffected by the redirect.
- [Submit a server](https://ai.mcpharbor.dev/submit) — publish your own MCP server listing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@lbesecker195
lbesecker195 merged commit 4fac3c7 into main Sep 19, 2026
3 checks passed
@lbesecker195
lbesecker195 deleted the seo/redirect-unknown-pages branch September 19, 2026 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Redirect unknown pages to the home page with a 301

1 participant