The .htaccess Redirect Generator builds an Apache Redirect directive from an old path, a new path, and the redirect type you choose, so a moved page keeps its traffic and search equity instead of returning a 404. Enter the source path beginning with a slash, the destination path or full URL, and pick permanent (301) or temporary (302).
How It Works
The tool validates both paths, rejecting a source that does not start with a slash, a protocol-relative double-slash path, and any value containing line breaks, which would corrupt the .htaccess file. It then emits one line in Apache's mod_alias format. For a permanent move of /old-page to /new-page the output is:
Redirect permanent /old-page /new-page
Choose temporary and the same inputs produce Redirect temporary /old-page /new-page. The word form is equivalent to the numeric 301 and 302 codes for the Redirect directive.
Parameters
| Input | Required | Meaning | |---|---|---| | From path | Yes | The old URL path on your site, starting with / | | To path | Yes | The destination path or full URL | | Redirect type | Yes | Permanent (301) for final moves, temporary (302) for tests and short-term changes |
301 versus 302
A 301 tells browsers and search engines the move is permanent: link equity consolidates onto the new URL and browsers cache the redirect aggressively, which makes mistakes hard to undo for returning visitors. A 302 keeps the original URL indexed and is not cached as strongly, so it suits staging tests, seasonal swaps, and any destination you may roll back. When in doubt during a migration test, start with 302 and switch to 301 once the destination is confirmed final.
Worked example
A blog post moves from /blog/seo-tips to /guides/seo-tips permanently. Entering from = /blog/seo-tips, to = /guides/seo-tips, type = permanent generates Redirect permanent /blog/seo-tips /guides/seo-tips. Adding that single line to the .htaccess file in the web root makes Apache answer every request for the old path with a 301 to the new one, no restart needed on typical shared hosting.
Redirect versus RewriteRule
The Redirect directive (mod_alias) is the right tool for simple one-to-one path moves. Pattern-based moves, such as sending a whole retired directory to a new structure, need RewriteRule with regular expressions and flags like [R=301,L], which this generator does not produce. Mixing the two modules carelessly can create loops, because mod_alias and mod_rewrite run at different phases; keep all redirects for a site in one system where possible.
Deployment checks
Back up the existing .htaccess first, because a single syntax error takes the whole site down with a 500. Add one rule, then request the old URL and confirm the status code and final destination with a header checker. Watch for chains (old to interim to final) and collapse them to a single hop, and confirm the destination itself returns 200.
Limitations
The generator creates text rules only; it does not inspect your server configuration, detect conflicts with existing rules, or verify the destination exists. .htaccess itself only works on Apache servers with overrides enabled; Nginx and other servers need their own configuration syntax.
Ordering and multiple rules
When several Redirect lines could match a request, Apache applies the first matching rule in the file, so put specific paths above general ones. A redirect for a single retired page should sit above any rule covering its whole directory, or the directory rule wins and the page lands in the wrong place. After any migration, audit the file for rules pointing at URLs that are themselves redirected, and collapse those chains: every extra hop slows users and leaks a little of the consolidation you redirected to preserve.
Testing the rule before and after
Before deploying, confirm the destination URL returns a 200 on its own; redirecting to a 404 is worse than no redirect. After adding the line, request the old URL with a header tool and check three things: the status is the 301 or 302 you intended, the Location header is exactly the destination, and the destination loads without a further redirect. Finally, click through the old URL in a private browser window, because browsers cache permanent redirects and can hide a mistake from the person who made it while showing it to everyone else, or the reverse.
What Redirect cannot do
The Redirect directive matches by URL path prefix only. It cannot condition on the hostname, so forcing the www or non-www version of a site, or upgrading HTTP to HTTPS by host, requires RewriteRule with a RewriteCond on the host or protocol instead. It also cannot pattern-match with regular expressions; RedirectMatch is the mod_alias sibling that can. Knowing which of the three tools a job needs, Redirect, RedirectMatch, or RewriteRule, is most of .htaccess redirect craft; this generator covers the first, simplest, and most common case.
Frequently Asked Questions
Where do I paste the generated rule?
Into the .htaccess file in your site's web root (often public_html), above WordPress or framework rules if the redirect must win. Keep a backup of the file before editing.
Can a redirect rule create a loop?
Yes, if the destination pattern also matches the source rule, or two rules point at each other. Test the exact old URL after adding a rule and check that it lands on a 200 page in one hop.
Does a 301 pass all link value?
Modern search engines consolidate essentially all ranking signals through a permanent redirect, but the consolidation is not instant. Keep redirects in place for at least a year after a migration.