SEO · Apache
htaccess redirect generator.
Paste your old and new URLs and get ready-to-paste Apache lines: Redirect, RedirectMatch or RewriteRule, plus the http to https and www rules. It flags loops, duplicates and redirect chains before they reach your server.
Inputs
.htaccess lines
Press Generate .htaccess to build the rules.
How the three styles differ
Redirect (mod_alias) is the simplest form: Redirect permanent "/one" "http://example.com/two", which is the example in the Apache docs. Its status can be permanent (301), temp (302, the default), seeother (303), gone (410) or a numeric code from 300 to 399. It matches by prefix, so the docs note that extra path after the match is appended to the target: a request for /service/foo.txt goes to the target followed by /foo.txt.
RedirectMatch takes a regular expression instead of a path and can reuse captured groups in the target, for example RedirectMatch "(.*)\.gif$" "http://other.example.com$1.jpg" (also from the docs). RewriteRule (mod_rewrite) is the tool for anything more complex; the mod_alias docs themselves say to use mod_rewrite for tasks like manipulating the query string. This generator escapes your path and anchors it with ^ and $ so only that exact URL matches. In .htaccess, mod_rewrite patterns do not see the leading slash, so the generated pattern leaves it off.
Worked example. The default list above, in Redirect style with a 301, produces:
Redirect permanent "/old-page" "https://www.example.com/new-page"
Redirect permanent "/blog/2019/launch" "/blog/launch"
Redirect permanent "/pricing-old" "/pricing"
With "Force http to https" and "Redirect to www" for example.com, one extra block is added so a visitor on http://example.com/ reaches https://www.example.com/ in a single hop:
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^ https://www.example.com%{REQUEST_URI} [R=301,NE,L]
The HTTPS test follows the Apache docs example (RewriteCond %{HTTPS} off, then a rule with [R=301,NE,L]). The www condition and the single-hop combination are this tool's own pattern built from those directives.
Before you paste it
- RewriteRule needs mod_rewrite and
RewriteEngine On. In .htaccess it also needsAllowOverride FileInfoin the server config; if the server does not allow it, the rules are ignored or you get a 500 error. RedirectandRedirectMatchin .htaccess also needAllowOverride FileInfo.- An
Rflag without a code is a 302, the Apache default. This tool always writes the code. - Back up the current .htaccess, paste, and test the old URLs in a private window. Browsers cache 301s hard, so test temporary first if you are unsure.
- This generator covers Apache only. nginx and other servers use different directives and are not covered here.
Frequently asked
Which should I use, Redirect or RewriteRule?
Use Redirect for simple moves where prefix matching is fine. Use RewriteRule when you need an exact match, a condition (host, HTTPS) or query string handling.
Can I mix both styles in one file?
Yes, and this tool does it when you add HTTPS or www rules to Redirect output. The Apache docs do not prescribe an order between the two modules, so confirm the result with a test request.
Why was a line skipped?
Lines are skipped, with a message, when they have a query string in the old path, redirect to themselves, repeat an earlier rule, or have a target that is not a URL or a path.
Is my list uploaded?
No. Everything is generated in your browser.
Sources
- Apache HTTP Server documentation, mod_alias (Redirect and RedirectMatch syntax, status keywords, default 302, .htaccess needs AllowOverride FileInfo). Checked 2026-10-01.
- Apache HTTP Server documentation, mod_rewrite (RewriteEngine, RewriteCond, RewriteRule, R/L/NE flags, %{HTTPS}, per-directory patterns without leading slash). Checked 2026-10-01.
Scope of this generator
This tool only writes text. It cannot see your server, so it cannot confirm that mod_rewrite is on, that .htaccess is allowed, or that a rule behaves as intended. Test on a staging copy first.