Return correct status codes for removed pages

Status codes are the first thing a crawler reads. Use 404 for URLs that never existed or may return, 410 for content removed for good, and 301 only when a real replacement exists. Check the status at the edge, because CDNs and rewrites routinely turn a correct framework 404 into a 200.

mediumIn codeimpact effort

Why this matters

404 for unknown URLs, 410 for permanent removals, never 200 with an apology.

Get the full breakdown

The extended brief explains when this works, when it does not, and the trade-offs. Join the waitlist and it unlocks for every tip when sign-in opens; MCP access is the paid part.

Join the waitlist

Before you start

  • A list of removed or retired URLs

How to apply it

  1. Classify each removed URL General best practice

    For every retired URL decide one of three outcomes: 301 to a genuine replacement, 410 for permanent removal, 404 for unknown or temporary absence.

    Check: Every URL in the removal list has exactly one assigned outcome in the migration sheet.

  2. Implement status at the routing layer

    Set the status in the server response, not in a client-side redirect. Remove catch-all rewrites that send unknown paths to the homepage.

    Check: curl -sI your production domain/retired-page returns 410 with no Location header.

  3. Sweep the edge for rewrites General best practice

    Check CDN and host rules for SPA fallbacks or 'always 200' behavior. Compare origin and edge responses for two known-missing URLs.

    Check: Edge and origin return the same status code for the sampled missing URLs.

Get the prompt for your agent

A ready-to-paste prompt for your agent that implements this tip and verifies the result in your repo.

Join the waitlist

Source: seo-mcp playbook · curated entry · report an error

Framework notes

nextjs-app

Use `notFound()` for 404. Next.js has no built-in 410 helper, so return a `Response` with status 410 from a route handler or middleware.

wordpress

Use `status_header(410)` for retired posts before rendering, and `wp_safe_redirect($url, 301)` only when a replacement exists.

Official references

Let your agent apply this + 161 more tips.

Pre-order — $19