.htaccess Redirect Generator

Paste a list of old-path-to-new-URL mappings and get ready-to-use Apache .htaccess Redirect rules, 301 or 302. Runs entirely in your browser.

Loading tool…

Worked examples

  • Two 301 redirects to a new domain and a new internal path

    The everyday case after a migration: old URLs permanently redirect, one to a full external URL and one to a new path on the same site.

  • Space-separated mapping without arrow syntax

    The parser also accepts a plain space between the old path and destination, and adds the leading slash automatically if you leave it off.

  • A batch of temporary 302 redirects

    Switching the status to 302 marks every rule as a temporary redirect — useful during an A/B test or a staged rollout you plan to reverse later.

What this tool does

This tool converts a plain list of old-path-to-new-destination mappings into ready-to-use Apache .htaccess Redirect rules, wrapped in an <IfModule mod_alias.c> block. Choose 301 (permanent) or 302 (temporary), paste your mappings one per line, and get a complete rule block you can paste directly into your .htaccess file.

When you need it

  • Migrating a site's URL structure and needing every old URL to redirect to its new location, so existing bookmarks, backlinks and search rankings carry over instead of dead-ending in a 404.
  • Merging or restructuring content — combining two pages into one, moving a section to a new path — where each moved URL needs its own explicit redirect.
  • Pointing an old domain or an old page at a new external URL entirely, such as after consolidating multiple sites into one.
  • Quickly generating a batch of redirects from a spreadsheet or migration plan without hand-typing each Redirect line and risking a typo in the directive syntax.

Why 301 vs 302 matters

A 301 tells browsers and search engines the move is permanent — search engines update their index to point at the new URL, and browsers may cache the redirect for a long time. A 302 says the move is temporary, which tells crawlers the original URL is the one to keep indexed. Using 301 for a redirect that's actually temporary can cause search engines to drop the original URL prematurely and leave browsers holding a cached redirect you later can't easily undo; Google has said a 302 that stays in place for a long time is eventually treated as permanent, but a 301 states your intent clearly from the start. Pick based on whether you intend to reverse the change later, not just on which one sounds more authoritative.

Where this rule block belongs

The generated block uses Apache's mod_alias module via the Redirect directive, which is a separate module from mod_rewrite. The two are not guaranteed to run in the order they appear in the file, and Apache's documentation advises against mixing them for the same URLs, so if your site already has RewriteRule lines that could match the same paths, test the redirects after adding them. Placing redirect rules near the top is conventional so they're easy to find. If your host or setup uses mod_rewrite exclusively and doesn't have mod_alias enabled (uncommon, but it happens on some minimal Apache installs), these rules won't take effect — check with your host if a rule doesn't seem to apply.

Mapping format

Each line describes one redirect as an old path followed by its destination, either separated by -> or by plain whitespace — /old-page -> https://example.com/new-page and /old-page https://example.com/new-page both work. The destination can be a path on the same site or a full URL to a different domain. A leading slash is added to the source path automatically if you leave it off. A space inside a destination URL is written as %20, and a source path containing a space is quoted. Lines with no destination are skipped, and if no line is usable the tool reports an error instead of producing an empty block.

Limits

This tool generates mod_alias Redirect lines, which match on the URL path only. Two consequences are worth knowing. First, Redirect is prefix-based: Redirect 301 /blog /articles also sends /blog/my-post to /articles/my-post, so a short old path can catch more URLs than you intended. Second, a Redirect can never match a query string, so a source such as /page?id=5 is rejected rather than written as a rule that would silently never fire; to redirect on a query string you need RewriteCond %{QUERY_STRING} with a RewriteRule, written by hand. Regular-expression redirects (RedirectMatch) and other mod_rewrite logic are likewise outside what this generator produces.

Frequently asked questions

Is my URL list uploaded anywhere?
No. The rules are generated entirely in your browser from the mappings you paste in; nothing is sent to a server.
What format should each line be in?
Either "/old-path -> new-destination" or "/old-path new-destination" separated by whitespace — one mapping per line. The destination can be a full URL or a path on the same site. Redirect matches the URL path only: it is prefix-based (/blog also catches /blog/post) and cannot match a query string, so a source containing ? is rejected.
Where does this rule block go in my .htaccess file?
Near the top of the file is conventional. Redirect comes from mod_alias, which is a different module from mod_rewrite, and Apache does not guarantee the two run in file order, so if you already have RewriteRule lines that could match the same URLs, test the redirects after adding them.
Should I use 301 or 302?
Use 301 (permanent) for URLs that have moved for good — it tells browsers and search engines to update their records. Use 302 (temporary) when the redirect might be reversed, such as during a test or a maintenance window.