.htaccess Redirect Generator
Paste old and new URLs, get redirect rules — with the loops and chains caught before they go live.
Rules
.htaccess takes the whole site down with a 500 error, and the file is read on every
single request.What the .htaccess Redirect Generator does
When a URL changes, a 301 redirect is what tells search engines the page has moved permanently and transfers most of its accumulated ranking signals to the new address. Without one, the old URL 404s, every link pointing at it is wasted, and the new page starts from nothing.
This generator takes a plain list of old and new paths and produces the rules for three
environments: Apache .htaccess, Nginx location blocks, and the
_redirects file used by Netlify and Vercel. It escapes regex metacharacters in the source
path, which matters because a full stop in a path such as /shoes.html is a wildcard in
an Apache rewrite rule if left unescaped.
Two structural problems are detected before the rules go anywhere near a server. Loops are rules that redirect to themselves or to each other, which produce a redirect loop and a browser error. Chains are rules where A points to B and B points to C; browsers follow them, but each hop adds latency and Google may stop following after several hops. The fix is always to point A directly at C, and the tool tells you which rules need it.
The optional HTTPS and www rules handle canonicalisation at the host level. Order matters in
Apache and the generated file gets it right: force HTTPS first, then strip www, then apply page
redirects, so a request to http://www.example.com/old resolves in one chain rather than
bouncing.
One caution about .htaccess specifically: Apache reads it on every request, and a
syntax error returns a 500 for the entire site rather than failing quietly. Back the file up before
you edit it, and test on a staging server if you have one.
How to use it
- List your redirects, one per line, as old path then new path separated by a comma.
- Choose your server and keep 301 unless the move is genuinely temporary.
- Fix any loops, and flatten any chains so each old URL points straight at its final destination.
- Back up your existing config, then add the rules and test several URLs before considering it done.
A worked example
Four redirects become this Apache block:
<IfModule mod_rewrite.c>
RewriteEngine On
# Page redirects
RewriteRule ^blog/2024/03/old\-shoe\-guide$ /guides/running-shoes-flat-feet [R=301,L]
RewriteRule ^shoes\.html$ /shop/stability-shoes [R=301,L]
RewriteRule ^about\-us$ /about [R=301,L]
</IfModule>
Note the escaped full stop in shoes\.html. Unescaped, . matches any
character, so the rule would also fire for shoesXhtml and similar — harmless here,
but the same mistake in a broader pattern can redirect URLs you never intended.
The chain warning is the one worth acting on. If you add /about, /about-the-team to a
list that already contains /about-us, /about, the tool flags it: a visitor hitting
/about-us now takes two hops. Change the first rule to point at
/about-the-team directly.
Frequently asked questions
301 or 302?
301 for anything permanent, which is nearly always what you want when a URL changes. It passes ranking signals to the new URL. A 302 signals a temporary move and does not consolidate signals the same way — use it only when the original really will return.
How long should I keep redirects in place?
Indefinitely for anything with inbound links. Google has said it treats a 301 as permanent after roughly a year of consistent crawling, but external links and bookmarks never expire. Removing an old redirect is how a site quietly starts 404ing years-old links.
What is a redirect chain and why does it matter?
A chain is A redirecting to B redirecting to C. Browsers follow it, but each hop adds a round trip, and crawlers may stop following after several. Always point the original URL straight at the final destination.
When should I use 410 instead of 301?
When content is genuinely gone with no equivalent replacement. A 410 tells crawlers to drop the URL rather than keep retrying, which is faster than a 404. Redirecting an unrelated deleted page to your homepage is worse than either — Google treats that as a soft 404.