.htaccess Redirect Generator for Apache and Nginx
An htaccess redirect generator writes the server rules that send visitors and search engines from an old address to a new one. Choose a single page, a bulk list, www or non-www, HTTP to HTTPS, trailing slashes, a folder or a whole domain move, and this free generator returns an Apache .htaccess block and the matching Nginx rules.

.htaccess Redirect Generator
Technical SEO
About this tool
Every time a page moves without a redirect, the links and rankings it earned lead to a "page not found" error instead. A 301 redirect passes visitors and most of that value to the new address; a 302 says the move is temporary. Writing the rules by hand is where things go wrong: a missing flag, a rule in the wrong place or a pattern that matches too much can trap a whole site in a redirect loop.
The generator escapes special characters in your paths, keeps query strings where they belong, and writes each rule for both servers: mod_rewrite rules for Apache and LiteSpeed .htaccess files, and return or rewrite rules for an Nginx server block. Bulk mode takes up to 200 old,new pairs, one per line, reports any line it could not use, and flags chains where one redirect leads to another.
Test every new rule before you rely on it: open the old address in a private window, or run curl -I, and check that it lands on the new page in one hop; our redirect checker does this for the www and HTTPS versions of a domain. Start with a 302 while testing, because browsers cache 301 redirects hard, then switch to 301 once everything is right. SEO SMO HUB builds and tests redirect maps like this for every site migration we manage.
Frequently asked questions
How do I create a 301 redirect in .htaccess?
Choose "single page" above, enter the old path and the new URL, pick 301 and generate. You get a RewriteRule block to paste into the .htaccess file in your site root, under RewriteEngine On and above any CMS rules. For a whole list, use bulk mode and paste old,new pairs one per line; the generator writes every rule for you.
Should I use a 301 or a 302 redirect?
Use 301 when the move is permanent, such as a new URL structure, HTTPS or a new domain: search engines transfer the old page's signals to the new one. Use 302 for temporary moves, such as a seasonal page or maintenance. While testing, a 302 is safer, because browsers cache 301s and keep redirecting even after you fix a mistake.
Where do I put the .htaccess rules?
In the .htaccess file in your site's root folder, the same folder as index.php or index.html. Place the redirects above any CMS block, such as the lines WordPress adds between BEGIN WordPress and END WordPress, because rules run in order and the CMS block would otherwise catch the request first. Back up the file before editing.
Why does my redirect cause a loop?
A loop happens when a rule matches its own target, for example one rule adding a trailing slash while another removes it, or forcing HTTPS behind a proxy that talks to your server over plain HTTP. Check that no two rules undo each other, and behind Cloudflare or a load balancer test the X-Forwarded-Proto header instead of HTTPS.
Can I generate bulk redirects for a site migration?
Yes. Bulk mode accepts up to 200 old,new pairs, one per line, and writes a rule for each in both Apache and Nginx syntax. It reports lines it cannot parse and warns about chains, where an old URL points to another old URL. For larger migrations, split the map into batches or ask us to handle the migration end to end.
