SEO

A 301 redirect map, one row per URL

A 301 redirect map is an old→new table with one row per URL and one target. Chains and 404 destinations show up in a script before Google finds them.

Key points

  • 301 and 308 are both permanent: a 308 keeps the HTTP method, a 301 does not, and Google treats them alike.
  • A healthy map has one row per old URL and always points to a destination that answers 200.
  • The browser stores a 301: a wrong redirect is hard to undo for anyone who already visited the page.

A 301 redirect map is a table with one row per old URL and one final destination. When a row points to another row, the chain loses signals and time: the map is checked with a script, not by eye.

Where the rows come from

Rows are not invented: they come from three verifiable sources. The 404 report in Search Console says which URLs Google tried to read; the server access log says which URLs people requested; the old sitemap says which URLs really existed. The first command extracts the most requested paths that answer 404 today.

awk '$9 == "404" {print $7}' access.log | sed 's/?" HTTP.*//' | sort | uniq -c | sort -rn | head -n 20 > missing.txt
wc -l missing.txt

The command reads field 7 of the combined log, which holds the requested path, keeps the rows with status 404, strips the query string and sorts by frequency. missing.txt keeps the twenty most requested broken paths: candidates for the map, not every 404 on the site. A path requested once can be ignored; one requested two hundred times is a broken external link.

One map, one destination

  • One row per old URL: two rules for the same path make the result depend on server order.
  • Final destination, not an intermediate one: if /a points to /b and /b points to /c, the map sends /a to /c.
  • The destination answers 200: a redirect to a 404 is worse than no redirect.
  • Permanent redirects only: 301 or 308. A 302 tells Google the old URL will return, and it stays in results.

Checking before deployment

while IFS=
\t' read -r from to; do code=$(curl -s -o /dev/null -w "%{http_code}" "https://example.com$from") echo "$code $from -> $to" done < redirects.tsv

The script reads a two-column file separated by a tab, old URL and new URL, and requests each old URL without following the redirect. A row printing 200 means the redirect is not live; 301 or 308 is the expected case; a 404 on the destination only shows when following the redirect, with curl -L. Google's documentation on redirects, read on 1 November 2026, confirms that 301 and 308 both mark a permanent move and that a temporary redirect keeps the old URL in results.

The EneUI catalogue

On large catalogues the risk is the slug change: the 111,985 records under /components, the 1,556 blocks under /blocks and the 30 categories such as /blocks/category/table with 13 blocks are public URLs. When a source renames itself the record moves, and without a map row the old URL dies. Our rule: the slug never changes; when it does, the redirect row lands in the same commit. Checked on 1 November 2026.

The limitation

A 301 is stored by the browser, often with no expiry: someone who already visited the old URL keeps landing on the new one after the rule is removed. That is why the map is tested in staging, and why a wrong redirect is not undone by a deploy. The map also cannot repair external links pointing at a 404 that never existed: those need new links or a page that answers.

Where to continue

Locale redirects in middleware are in middleware for locale redirects; the difference between canonical and redirect is in canonical, the practical guide; the sequence for getting indexed is in getting a site indexed by Google.

Frequently asked questions

301 or 302?

301 when the move is permanent, 302 when it is temporary. With a 302 Google keeps the old URL in results, so do not use it for a permanent slug change.

Are 301 and 308 equivalent for Google?

Yes, both mark a permanent move. A 308 preserves the request method, a 301 does not; for ranking the difference does not matter.

How many rows can a map hold?

As many as needed, without duplicates: one row per old URL. On a large site the map lives in a file or a table, not by hand in code.

Does a redirect pass every signal?

Google uses the redirect as a strong signal to move the canonical, but it is not a mathematical guarantee. A chain of three redirects weakens it: one hop is better.

How do I find the redirects to create?

From the 404 report in Search Console, the access log and the previous sitemap. A URL requested many times and missing is the first candidate.