Skip to content

Redirect, canonical and 404 hygiene

One canonical host, no redirect chains, real 404s and 410s, and every old URL sent somewhere useful.

  • Free, no sign-up
  • 45 to 90 minutes with an agent
  • By Devvrat Hans
  • Version 1.0, updated Oct 26, 2026

1Your site and stack

Optional. The prompt adapts as you type; leave a field blank and the agent works it out.

2Copy it into your agent

redirects-and-404s.md70 lines, about 965 tokens

Paste into any coding agent: Claude Code, Cursor, Codex, Copilot, Windsurf or Cline.

# Redirect, canonical and 404 hygiene

Every extra redirect hop, page that returns 200 for a missing item, and old URL that dead-ends wastes crawl budget and visitor trust on the production site. Clean up how the site answers for URLs it does not serve, so every URL either works, redirects once to the right place, or says clearly that it is gone.

Site: not given. Find the production URL in the project config, or ask me.

## Ground rules

1. Read before you write. Explore the parts of the codebase this job touches and tell me what is already in place.
2. Plan, then stop. Give me a numbered plan: what you will change, in which files, and why. Wait for my approval before editing anything.
3. Fix things at their source (the shared layout, the config, the generator), not with one-off patches page by page.
4. Keep the project's conventions: its framework APIs, file layout, naming and code style. Add no new dependency without asking.
5. Where something is already done well, say so and leave it alone.

## You will not

- Edit `.env` files, secrets or API keys, or print their values.
- Deploy, push, merge or publish anything.
- Delete data, or run migrations or scripts against a production database.
- Add tracking, third-party scripts or links to any site I did not ask for.
- Change copy, design or behaviour that this job does not need.
- Redirect missing pages to the homepage.
- Change DNS or host settings outside this repository.

## Your stack

- Framework: Work out the framework, router and build output from the project files (package.json, lockfiles, framework config) before planning, and say which you found.
- Host: Work out where the site is hosted from the config files (vercel.json, netlify.toml, wrangler config, Dockerfile, fly.toml) and say which you found.

## Steps

### 1. Map how the site answers

Find every place redirects and error statuses are decided: framework config, middleware, host config (the current host), and page code that renders a 'not found' state. List the redirects that exist, and which page types can render an empty or missing state.

### 2. One canonical host and form

Pick one host (`www` or not) and one trailing-slash form, and make every other variant redirect there in a single 301 (HTTP to HTTPS and `www` to apex in the same hop where the host allows). No redirect chains: an old URL should reach its final destination in one step.

### 3. Real status codes

- A missing item (deleted product, unknown slug, typo) must return 404 with a helpful page: search, popular links, a way home. Not a 200 page that says 'not found' (a soft 404), and not a redirect to the homepage.
- Content removed for good can return 410.
- Empty list pages that will fill later should still return 200 but carry `noindex` until they have content.
- Server errors return 500 with a friendly page, never a 200.

### 4. Old URLs

When a slug changes, record the old one and 301 it to the new one. Find renamed routes in the git history and in analytics or search data if I can share it, and add 301s for any that still get traffic or links. Keep the redirect list in one place in code.

### 5. Guard it

Add tests that an unknown slug for each dynamic page type returns 404, and that a sample of old URLs redirect once to the right place.

## Done means

- [ ] Every host and slash variant redirects to the canonical form in one hop.
- [ ] No redirect chains remain.
- [ ] Unknown items return 404 with a helpful page; nothing returns a soft 404.
- [ ] Changed slugs and renamed routes 301 to their new URLs from one redirect list.
- [ ] Tests cover 404s for each dynamic page type.

## Report back

When you finish, give me:

- what you changed, file by file;
- anything you skipped, and why;
- anything I must do by hand (DNS records, dashboards, accounts, deploys);
- how to check each change on the live site.

One-line version

For agents that can read a URL. It fetches this prompt with your settings applied.

Read https://abacklaunch.com/prompts/redirects-and-404s.md and follow it for this project.

3Check the result

When the changes are live, run these free checks. Add your site URL above and each one opens already running on it.

This prompt will not

  • Edit .env files, secrets or API keys, or print their values.
  • Deploy, push, merge or publish anything.
  • Delete data, or run migrations or scripts against a production database.
  • Add tracking, third-party scripts or links to any site I did not ask for.
  • Change copy, design or behaviour that this job does not need.
  • Redirect missing pages to the homepage.
  • Change DNS or host settings outside this repository.

It reads your code first, shows you a plan, and waits for your approval before it changes anything.

What you get

  • One canonical host and URL form, reached in a single redirect
  • Real 404 and 410 status codes instead of soft 404s
  • 301s for old and renamed URLs, kept in one list
  • Tests that keep it that way

How to use this prompt

  1. 1

    Describe your stack

    Add your site, framework and host. The prompt adapts; blank fields are left for the agent to work out.

  2. 2

    Paste it into your agent

    Open your project in Claude Code, Cursor, Codex, Copilot, Windsurf or Cline, and paste the prompt or the one-line version.

  3. 3

    Approve the plan

    The agent reads your code, shows you a plan with the files it will touch, and waits. Change anything you disagree with.

  4. 4

    Check the result

    When the changes are live, run the free checks below on your site to confirm each fix.

What the agent does

Every extra redirect hop, page that returns 200 for a missing item, and old URL that dead-ends wastes crawl budget and visitor trust on the production site. Clean up how the site answers for URLs it does not serve, so every URL either works, redirects once to the right place, or says clearly that it is gone.

  1. 1. Map how the site answers

    Find every place redirects and error statuses are decided: framework config, middleware, host config (the current host), and page code that renders a 'not found' state. List the redirects that exist, and which page types can render an empty or missing state.

  2. 2. One canonical host and form

    Pick one host (www or not) and one trailing-slash form, and make every other variant redirect there in a single 301 (HTTP to HTTPS and www to apex in the same hop where the host allows). No redirect chains: an old URL should reach its final destination in one step.

  3. 3. Real status codes

    • A missing item (deleted product, unknown slug, typo) must return 404 with a helpful page: search, popular links, a way home. Not a 200 page that says 'not found' (a soft 404), and not a redirect to the homepage.
    • Content removed for good can return 410.
    • Empty list pages that will fill later should still return 200 but carry noindex until they have content.
    • Server errors return 500 with a friendly page, never a 200.
  4. 4. Old URLs

    When a slug changes, record the old one and 301 it to the new one. Find renamed routes in the git history and in analytics or search data if I can share it, and add 301s for any that still get traffic or links. Keep the redirect list in one place in code.

  5. 5. Guard it

    Add tests that an unknown slug for each dynamic page type returns 404, and that a sample of old URLs redirect once to the right place.

Done means

  • Every host and slash variant redirects to the canonical form in one hop.
  • No redirect chains remain.
  • Unknown items return 404 with a helpful page; nothing returns a soft 404.
  • Changed slugs and renamed routes 301 to their new URLs from one redirect list.
  • Tests cover 404s for each dynamic page type.

Questions

What is a soft 404?

A page that tells the visitor something does not exist but returns a 200 status. Search engines may keep it indexed or treat it as low quality. The fix is to return a real 404.

Is it OK to redirect missing pages to the homepage?

No. Search engines treat that as a soft 404, and visitors land somewhere they did not ask for. Redirect only to a page that replaces the old one; otherwise return 404.

301 or 308?

Both are permanent. 308 keeps the request method, which matters for forms and APIs; for page URLs either works and most frameworks use 308 or 301 by default.

Does this prompt add links to Aback Launch to my site?

No. Nothing in the prompt mentions Aback Launch or asks your agent to link to us. The only exception is an optional badge step, which stays off unless you tick it. Some prompt libraries slip their own link into your codebase by default; we think that should always be your choice.

Which coding agents does it work with?

Claude Code, Cursor, Codex, GitHub Copilot, Windsurf, Cline, and any agent that can read your project and edit files. You can copy it as a plain prompt, save it as a Claude Code skill or a Cursor rule, or add it to AGENTS.md.

Is it safe to run on my real codebase?

The prompt makes the agent read first, show a plan and wait for your approval, and it forbids touching secrets, deploying and deleting data. Still review the changes and run your tests before you deploy, as with any change.

Changelog

  • v1.0First version.

Launch your startup on Aback Launch

Get a launch page that search engines and AI assistants can read, a place in the weekly launch list, and a review by a real person. Free to join.