Htaccess Redirect Generator

Generate correct .htaccess rules for 301/302 redirects, www/non-www, HTTPS enforcement, trailing slashes and domain moves.

What it does: Permanent redirect — passes link equity, ideal for moved pages.
Apache with mod_rewrite required. Back up your .htaccess first; a syntax error causes a 500 error site-wide. On Nginx, use server-block return 301 / rewrite directives instead.
.htaccess rules
Redirect 301 /old-page.html https://example.com/new-page/

Website Management Tools

About the Htaccess Redirect Generator

This tool writes .htaccess rules for Apache servers without you needing to learn the syntax. It covers 301 and 302 single-page redirects, forcing HTTPS, choosing www or non-www, and moving a whole site to a new domain.

A 301 is permanent and tells search engines to move a page's value to the new address, while a 302 is temporary. Forcing one version of your site, such as https without www, also avoids the same pages being reachable at several addresses.

A wrong rule can cause a redirect loop or take your site offline, so download a copy of your existing .htaccess before you edit it. These rules work on Apache and LiteSpeed servers. Nginx uses a different format and ignores this file.

How to use this tool

  1. 1Choose the redirect type.
  2. 2Enter the old path and new address, or your domain.
  3. 3Copy the rules it generates.
  4. 4Back up your .htaccess, add the rules at the top and test the address.

Best-practice tips

  • Use a 301 when a page has moved for good.
  • Redirect to the most relevant page, not always to the home page.
  • Test with the Redirect Checker, and avoid chains of several redirects.

Answers

Htaccess Redirect Generator FAQs

A 301 means the move is permanent. A 302 means it is temporary and the old address may return.

Related tools

Continue with these related website management tools.