Skip to content

.htaccess 301 & 302 Redirect Generator

Turn a list of old and new URLs into Apache .htaccess redirect rules, using Redirect or RewriteRule, with optional HTTPS forcing and query string passthrough.

alt_route .htaccess 301 & 302 Redirect Generator
verified Apache mod_alias & mod_rewrite rule generator active
3 Rules Configured • Apache 2.4+
Redirect Configuration
Supports relative paths or absolute external URLs 3 pairs
Generated Apache .htaccess Rules
•
Paste at the top of your server root .htaccess file 0 lines

What this tool does

Write one redirect per line as old-path new-url, choose the status code (301, 302, 307 or 308) and the syntax (Redirect or RewriteRule), and the tool writes the Apache rules inside an <IfModule mod_rewrite.c> block. Two checkboxes control Force HTTPS and Preserve Query String (QSA).

Example input:

code
TEXT
/old-page/ https://example.com/new-page/
/blog/2019/post/ https://example.com/blog/post/

How to use it

  1. Write one redirect per line as the old path, a space, then the new URL.
  2. Choose the status code (301, 302, 307 or 308) and the syntax (Redirect or RewriteRule).
  3. Tick Force HTTPS or Preserve Query String if you need them, then press Generate Redirect.
  4. Copy or download the rules, back up your current .htaccess, then add them above the WordPress block.
  5. Test each redirect with the redirect checker.

Which status code to use

  • 301 is a permanent move. Search engines transfer the old URL’s signals to the new one over time. Use it for renamed pages and site migrations.
  • 302 and 307 are temporary. Use them for short-term moves, like a maintenance page.
  • 308 is a permanent redirect that keeps the HTTP method, which matters only for POST requests.

What the generator does not do

It writes exact path matches. It doesn’t build regular-expression rules, handle wildcards, or match on host names or query strings. In RewriteRule mode the path you give is used as the pattern, so characters like . aren’t escaped. A dot will match any character. That is harmless for most URLs, but check anything with special characters.

It also can’t test your rules against your server.

Before you deploy

  • Back up your current .htaccess file. A syntax error can take the whole site down with a 500 error.
  • Put the new rules above the # BEGIN WordPress block on a WordPress site so they run first.
  • This only works on Apache, and LiteSpeed. Nginx needs a different syntax.
  • Test each redirect with the redirect checker and avoid chains, where A goes to B and B goes to C.

Will this work on Nginx?

No. The output is Apache syntax. LiteSpeed reads it too, but Nginx needs its own rewrite or return rules.

Where do I put the rules in WordPress?

In the .htaccess file in your site root, above the BEGIN WordPress comment, so they run before WordPress handles the request.

What does QSA do?

It keeps the query string when redirecting, so /old?id=5 can arrive as /new?id=5 in RewriteRule mode.

Can it redirect a whole folder?

Not with this tool. It writes exact matches only, so each old address needs its own line.

Which status code should I use for a permanent move?

Use 301 for a renamed page or a site migration, and 302 or 307 only for short-term moves such as a maintenance page. 308 is a permanent redirect that also keeps the HTTP method.