Htaccess Redirect Generator
Runs in your browser — your data is never uploaded.
Paste a migration list — old path, new path, one pair per line — and get mod_rewrite rules for .htaccess. Patterns are anchored at both ends, so a rule for /old does not also catch /old-prices, and the query-string behaviour is a choice you make rather than one you discover. Duplicate and self-referential rules are rejected instead of quietly producing a redirect loop.
0 characters · runs entirely in your browser
How to use Htaccess Redirect Generator
- 1
Paste your pairs, one per line: the old path, a space, then the new path or full URL.
- 2
Choose the status code and whether to keep the original query string.
- 3
Click “Generate” and paste the rules into .htaccess above your CMS’s front-controller rules.
Share
Embed this tool on your site
Paste this where you want the tool to appear. It runs entirely in your visitor's browser — no uploads, no account, no tracking.
Please keep the attribution line — it's what keeps these tools free.
Need a different size, a dark theme, or a different tool? Build an embed lets you preview it first.
Frequently asked questions
Should I use 301 or 302?+
301 for a move that is permanent, which is the case for a migration — it is the one that passes ranking signals. But browsers cache a 301 essentially forever, so a wrong one is not fixed by changing the server: that visitor’s browser never asks again. Test the mapping with a 302, then switch.
What happens to the query string?+
By default mod_rewrite appends the original query string, because none of the targets here specify one. That is usually what you want — it preserves ?utm_source= and other tracking. Choose “drop” and each target gets a trailing ?, which discards it. There is no third behaviour, and the difference is one character.
Why RewriteRule instead of Redirect?+
Because Apache’s Redirect directive matches by prefix and appends whatever followed. Redirect /old /new also sends /old-prices to /new-prices, which is occasionally what you want and usually a surprise. An anchored RewriteRule does exactly what the line says.
My rules are not firing.+
Two usual causes. The rules have to be above the front-controller block that most CMSs put in .htaccess, or that block rewrites the URL to index.php before yours are reached. And .htaccess is only read if AllowOverride permits it — on a server you control, put the rules in the vhost config instead and drop .htaccess entirely.