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.

Source: Apache HTTP Server docs (mod_alias, mod_rewrite) Checked 2026-10-01 · nothing leaves your browser

Advertisement

Inputs

Separate with a space, comma or ->. Lines starting with # are ignored. Targets are a full URL or a path starting with /.

.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

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

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.

Advertisement
Advertisement
Listening…