Skip to main content
KalkuNet

Apache .htaccess Redirect Generator — 301/302 mod_rewrite Rules

Generate Apache mod_rewrite 301 permanent redirects and HTTPS enforcement.

Runs in your browserWeb · HTTP, URLs & Redirects

Rename the file to .htaccess in the site's root folder. Needs mod_rewrite and AllowOverride FileInfo/All. Behind Cloudflare or a proxy %{HTTPS} is always off — enforce HTTPS at that proxy instead.

✓ 5 redirects ready, each going straight to its final URL in one hop.

When to use the Apache .htaccess 301/302 Redirect Generator

  • One hop to the final URL

    Every rule points straight at https:// and the main host name, so http://www.domain/old does not pass through three redirects in a row that waste load time and SEO value.

  • Query strings handled right

    Parameters such as ?utm_source are carried along by default, while old query-based URLs (produk.php?id=7) are matched with RewriteCond and their query is dropped with QSD.

  • The list is checked first

    Duplicate lines, self-redirects and redirect chains (A to B, then B to C) are reported with their line numbers before the rules reach the server.

  • Tested on a real Apache

    The generated rules are run on Apache with mod_rewrite, then every example URL is requested and its status code and Location header are compared.

Frequently asked questions

When should I use 301 and when 302?

301 for a permanent move: search engines transfer ranking to the new URL and browsers cache it. 302 or 307 for temporary cases such as promotions or maintenance.

Why is the file downloaded as htaccess.txt?

Many systems hide or refuse files whose names start with a dot. Rename it to .htaccess after uploading it to the site's root folder.

Do these rules slow the site down?

Slightly, because .htaccess is read on every request. For thousands of redirects, move the rules into the VirtualHost config or use a RewriteMap.

Can I move a whole old domain to a new one?

Yes. In the old domain's .htaccess, one rule RewriteRule ^(.*)$ https://new-domain.example/$1 [R=301,L] moves every path at once. Put the specific rules from this tool above it for pages whose address changed.

Learn more