URL rewrites are Magento’s mapping between the pretty URLs customers see (/leather-jackets/biker-jacket.html) and the internal routes that serve them. They are also your primary tool for preserving SEO equity when URLs change. Managed well, rewrites are invisible; managed badly, they decay into chains, conflicts and mysterious 404s. Here is how the system actually works.
How url_rewrite Works
Every product and category gets rows in the url_rewrite table mapping a request_path (the pretty URL) to a target_path (the internal route like catalog/product/view/id/123). Rewrites exist per store view - a French view has its own paths. When you rename a product URL key with “Create Permanent Redirect for old URL” ticked, Magento writes a new rewrite row redirecting the old path to the new one. Always tick that box.
The Automatic Redirect Setting
Stores > Configuration > Catalog > SEO: “Create Permanent Redirect for URLs if URL Key Changed” should be Yes on every store, forever. Unticked, every merchandiser renaming a product silently kills its old URL - and any rankings, links and bookmarks pointing at it.
Managing Redirects at Scale
Marketing > URL Rewrites lets you create custom redirects manually. For anything beyond a handful, work in bulk:
- CSV import via System > Import (entity type “URL Rewrites”) for planned migrations
- Programmatic creation via
UrlRewriteFactoryin a data patch or CLI command for repeatable, deployable migration logic
On platform migrations (from Magento 1, Shopify, WooCommerce) we generate rewrite rows from the old system’s URL map as part of go-live - a migration without a redirect map is an SEO reset.
The Failure Modes
- Redirect chains: A redirects to B, B to C. Chains leak link equity and slow crawling. Fix by pointing A directly at C. Audit chains with a crawl (Screaming Frog), not by guessing.
- Redirect loops: category A redirecting to B while B redirects to A, usually from bulk edits. The crawler finds these too.
- Duplicate request paths: two products with the same URL key produce suffixed URLs or overwrite each other. Enforce unique URL keys during imports.
- Table bloat: stores with aggressive auto-redirect plus frequent renames grow
url_rewriteinto the millions of rows, slowing the router. Prune redirects older than a sensible window (with an SEO-informed cutoff, not blindly).
Redirect Discipline
- 301 for permanent moves (products, categories), 302 only for genuinely temporary states (out-of-stock holding pages are usually better as 200 with a message)
- Redirect to the closest equivalent, not the homepage - a deleted product goes to its category
- Keep a canonical redirect map as a CSV in the repo for anything created outside Magento’s automation
URLs are contracts with customers and search engines. Magento gives you the tools to keep those contracts through every rename and migration - the settings above, plus a crawl audit per quarter, is all the discipline it takes.