Free tools that run in your browser. Use any tool without an account.

Favourites Cart
Sign in
Join free

Htaccess Redirect Generator

Apache rules

  • Free
  • Runs in your browser
  • No account needed

It writes ready-to-paste Apache .htaccess rules from a list of redirects. For example, one line 'Redirect 301 /old /new' produces the mod_alias line, or the tool emits RewriteRule when HTTPS or query string rules are needed.

.htaccess rules
# Redirects made with FreeToolr. Back up your .htaccess before changing it.
RewriteEngine On
# Page redirects
RewriteRule ^old-page/?$ /new-page [R=301,L]
RewriteRule ^blog/2019/summer-sale/?$ https://example.com/sale/ [R=301,L]
RewriteCond %{QUERY_STRING} ^id=12$
RewriteRule ^product\.php$ /shoes/trail-runner/ [R=301,L,QSD]
Lines skipped
None
Runs in your browser. Your files and values are not sent to us. Report a problem
Advertisement

About the Htaccess Redirect Generator

This tool builds Apache .htaccess redirect blocks in your browser from a simple list of old and new paths or URLs. You paste redirects one per line, pick status codes (301, 302, 307, 308), choose Redirect or RewriteRule output, and set force-HTTPS and www options. Nothing is uploaded to a server; the generator runs client-side so your data stays in your browser. The output is ready-to-paste .htaccess code for Apache or LiteSpeed and updates instantly as you type. The tool writes Redirect (mod_alias) lines for plain prefix moves and RewriteRule lines for exact matches, query-string cases or when HTTPS/www rules are requested. You can copy the result or share a link that reopens the same inputs. This saves time when you need bulk edits, consistent ordering, and proper query-string handling.

How to use it

  1. 1Paste redirects one per line as: old-path, then new path or URL
  2. 2Choose status code and whether to write Redirect or RewriteRule
  3. 3Set force HTTPS Yes/No and pick www option
  4. 4Copy the generated .htaccess block or share the link
Advertisement

Worked example

Inputs: Redirects (one per line): /old /new /path/page https://example.com/other /search?q=term /results Redirect type: 301 Write rules as: Redirect (simple, mod_alias) Force HTTPS: Yes www: Remove www Exact output (.htaccess): RewriteEngine On # Force HTTPS and remove www RewriteCond %{HTTPS} !=on [OR] RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC] RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,NE,L] # Redirects (written as RewriteRule because HTTPS or www rules are set) RewriteRule ^old/?$ https://example.com/new [R=301,L,NE] RewriteRule ^path/page/?$ https://example.com/other [R=301,L,NE] RewriteCond %{QUERY_STRING} ^q=term$ RewriteRule ^search/?$ https://example.com/results [R=301,L,NE,QSD]

How it works

Writes Apache rules"Redirect 301 /old /new" (mod_alias) also sends anything below /old to the same place below /new; RewriteRule matches the exact path onlyOld addresses with a ?query are always written as a RewriteCond on the query string plus a RewriteRule, because Redirect ignores query strings, and the old query is dropped with QSDWhen HTTPS, www or query-string rules are needed, every line is written as a RewriteRule (with an optional trailing slash) so the rules run in a predictable order; HTTPS and www rules come firstWorks on Apache and LiteSpeed, not on NginxResults update instantly as the visitor types; there is no calculate buttonVisitors can copy the result and share a link that reopens with their numbers

Source: Apache mod_alias documentationApache mod_rewrite documentationGoogle Search Central: 301 redirects. Last checked 11 November 2026.

What it is good for

  • Creates ready-to-paste .htaccess code in seconds
  • Runs entirely in the browser; nothing is uploaded
  • Handles query-string cases and bulk lists consistently
  • Generates Apache/LiteSpeed rules only; it does not output Nginx format
  • It does not run server-side tests or live-check HTTP headers
Advertisement

Questions people ask

Should I use Redirect or RewriteRule?

Use Redirect (mod_alias) for simple prefix moves because it is simpler. Use RewriteRule when you need exact matches, regex, host or protocol checks, or query-string handling.

How do query strings affect redirects?

Redirect (mod_alias) ignores query-string matching and can preserve queries by default. For matches that include a query string, this tool writes a RewriteCond on %{QUERY_STRING} plus a RewriteRule and uses QSD to drop the old query when appropriate.

Will these rules work on my host?

They work on Apache and LiteSpeed when .htaccess overrides are allowed and mod_rewrite is available. If you run Nginx or a CDN edge redirect, you must convert the rules to the platform format.

How do I force HTTPS and remove www in one rule?

The generator places HTTPS and www canonicalization rules first and redirects to a single target like https://example.com%{REQUEST_URI}. That avoids double hops and gives predictable ordering for later rules.

Do 301 redirects hurt SEO?

A single 301 redirect is the standard way to move content and preserve indexing signals. Avoid long redirect chains and many hops; Google recommends using 301 or 308 for permanent moves.

Can I bulk-import hundreds of redirects?

Yes. Paste hundreds or thousands of lines and the tool will emit a block of .htaccess rules. For very large sets consider server-level config or your CDN to avoid .htaccess performance issues.

Help keep every tool free

FreeToolr stays free because people help it grow. Share a tool you like, tell us what to build next, or support us on Ko-fi.

Advertisement
Advertisement