Redirect rule generator
Turn a list of old and new paths into Apache, nginx or Netlify redirect rules, with chains and loops caught first.
Use 301 for a move that is staying moved. A 302 passes no ranking signal on and is cached by nobody usefully.
Paths, not full URLs, for the old side. One row per redirect.
Redirect rules
# .htaccess — Redirect needs mod_alias, enabled by defaultBefore you ship this
- Note: Add at least one redirect.
How to use it
- Pick your server. The rules differ enough between Apache, nginx and Netlify that the wrong syntax simply does nothing.
- Choose 301 for a move that is staying moved. A 302 leaves the ranking on the old URL.
- Add one row per redirect: the old path on the left, the new path or full URL on the right.
- Check the warnings for chains and duplicates, then test on staging before deploying — a bad rule can take a whole site down.
The three mistakes
Redirect syntax is easy. What goes wrong is always one of three things: a chain, where A points at B and B points at C; a loop, where a rule sends a URL to itself and the browser gives up; or two rules with the same source, where the first one wins and the second never runs.
All three are invisible from a single row, which is why this checks the whole set rather than each line. A spreadsheet of redirects assembled over two years will almost always have at least one chain in it.
Trailing slashes
If your server normalises trailing slashes — most do — and your redirect disagrees with that normalisation, you get two redirects where you wanted one, and occasionally an infinite loop. Pick one convention for the whole site and make every redirect match it.
Redirect to the equivalent page, or do not redirect
When a page is genuinely gone and nothing replaces it, a 410 is honest and a 404 is fine. Redirecting it to the homepage is treated as a soft 404 anyway, so you gain nothing and you send a visitor somewhere that does not answer their question.
The test is simple: would someone who clicked the old link be satisfied landing on the new page? If not, that is not a redirect, it is a dead end with extra steps.
Order of evaluation
Apache and Netlify evaluate rules top to bottom and stop at the first match. nginx matches locations by its own specificity rules rather than file order, which is why a broad rule placed carelessly can swallow traffic meant for a narrower one. Either way: test a handful of real URLs with curl -I before and after you deploy.
Redirect rule generator FAQ
What is the difference between a 301 and a 302?
A 301 says the move is permanent, so search engines transfer the ranking signals to the new URL and eventually drop the old one. A 302 says the old URL is coming back, so the old page keeps the ranking and the new one earns none. Use 301 for a real move.
Why do redirect chains matter?
Each hop costs a round trip for the visitor and loses a little signal. Google follows up to about ten hops before giving up, but the real cost is simpler: a chain means your redirect map is out of date, and the next person to edit it will make it longer. Point every old URL at its final destination.
Should I use 307 and 308 instead?
They are the stricter versions: a 307 or 308 preserves the request method, so a POST stays a POST. For ordinary page moves a 301 is what everything expects and understands. Use 308 if you are redirecting an API endpoint where the method matters.
Do redirects lose ranking?
A single 301 to a genuinely equivalent page passes signals effectively, and Google has said there is no PageRank loss through a 301. What actually loses ranking is redirecting to a page that is not equivalent — pointing fifty deleted product pages at the homepage, where none of them has anything to do with the query that used to rank.
Should HTTPS and www redirects go in this list?
No. Handle those once at the server or CDN level as a single rule covering every URL, before any of these path rules run. Mixing a site-wide protocol redirect into a per-path list is how you get chains, where a visitor is bounced twice for one request.
How long should I keep a redirect?
At least a year, and in practice forever. Google needs months of recrawling to transfer signals, and old links keep arriving long after that — from emails, printed material and sites nobody will ever update. Redirect rules are cheap to keep and expensive to remove.
What happens to query strings?
It depends on the server, which is exactly why this catches people out. Apache appends the original query string in some configurations and not others; nginx drops it unless you ask for it. Decide deliberately whether tracking parameters should survive the hop, and test with a real URL.
What should I do with a page that has no equivalent?
Return 410 Gone, or 404 if you prefer. Redirecting an unrelated page to the homepage is treated as a soft 404 by Google and helps nobody: the visitor who clicked a specific link arrives somewhere that does not mention what they wanted.
Can I redirect a whole section with one rule?
Yes, and for a directory move it is far better than a thousand individual rules. A pattern rule that maps the old prefix to the new one is a single line to maintain. Keep individual rules for the exceptions where the path changed shape as well as location.
Do redirects slow the site down?
Each hop adds a round trip, typically a tenth to a third of a second depending on the connection, and it is worst on mobile. One redirect is acceptable; a chain of three on a page people reach from search is a real cost you can remove by pointing the first rule at the final URL.