htaccess Redirect Generator
Generate Apache .htaccess redirect rules from a list of old and new URL pairs, with the correct status code.
Everything you type here is processed on your own device. No input is sent to a server, logged, or stored.
What the htaccess Redirect Generator does
This htaccess redirect generator will generate Apache .htaccess redirect rules from a list of old and new URL pairs, with the correct status code. Paste your text in, pick the options you need, and copy the result straight back out. It is most often used for redirecting old URLs after a site restructure. If you need the other side of this job, there is also a nginx redirect generator.
How to use it
- Put one redirect per line as "old path, new URL".
- Pick the status code — 301 for permanent, 302 if you may reverse it.
- Choose Redirect for simple one-to-one moves or RewriteRule for pattern matching.
- Test every rule on a staging site before deploying.
How it works
Redirect and RewriteRule are not interchangeable. Redirect matches a path prefix and appends whatever follows to the target, so a Redirect on /blog also catches /blog/anything. RewriteRule matches a regular expression against the path with no leading slash, and matches nothing it is not told to.
That prefix behaviour is the usual surprise: a Redirect intended for one page silently captures an entire directory tree beneath it. Where you want exactly one URL redirected, use RedirectMatch with an anchored pattern, or a RewriteRule.
Chained redirects are worth avoiding. Each hop costs a round trip, and Google has said it follows a limited number before giving up. When a URL has moved twice, point the original at the final destination rather than at the intermediate.
Apache only reads .htaccess if AllowOverride permits it, and reading it on every request is slower than putting the same rules in the server configuration. On a server you control, put them in the vhost; .htaccess is for shared hosting where you cannot.
When to use it
- Redirecting old URLs after a site restructure.
- Mapping a list of changed URLs in bulk.
- Setting up redirects after a domain migration.
- Preserving link equity when URLs change.
Common mistakes to avoid
- Using Redirect for a single page and catching the whole directory beneath it.
- Deploying a 301 before testing, which browsers then cache for a long time.
- Creating redirect chains instead of pointing at the final destination.
Frequently asked questions
Should I use 301 or 302?
301 when the move is permanent and you are certain — it passes ranking signals and is cached hard. 302 while you might still reverse it.
What is the difference between Redirect and RewriteRule?
Redirect matches a path prefix and captures everything beneath it. RewriteRule matches a regex against the path and only what you specify.
Do redirect chains hurt SEO?
They cost a round trip each and search engines follow only a limited number of hops. Point the original URL at the final destination rather than chaining.