.htaccess Redirect Generator

Create Apache .htaccess page-level 301/302 rules plus HTTP → HTTPS and www / non-www redirects.

Runs in your browser Free
Common rules:

Page redirects

Paths must start with /. Spaces, quotes, braces and semicolons are not allowed.

Processed locally in your browser.

Redirects for shared hosting

Sites on cPanel, Plesk and shared hosting (including WordPress) usually handle redirects in the .htaccess file in the site root. The .htaccess Redirect Generator prepares rules with the correct syntax for you.

Generated rules

  • mod_alias Redirect lines for page redirects
  • Forcing HTTP to HTTPS
  • www to non-www, or the other way round (mod_rewrite)

Safe patterns

Host rules are created with escaped patterns, so dots and special characters don't cause unexpected matches. Paste the output at the top of your .htaccess file, and back up the file before making changes.

How to use .htaccess Redirect Generator

  1. Add old and new URL pairs.
  2. Choose the redirect type.
  3. Enable the HTTPS and www rules as needed.
  4. Paste the code at the top of your .htaccess file.

Why use this tool?

Create correct redirects for migrations and URL changes without knowing Apache syntax.

FAQ

My redirect doesn't work. What should I check?

Make sure mod_rewrite/mod_alias are enabled and AllowOverride permits .htaccess; 301s are cached, so clear the browser cache or test in a private window.

Where should I add the code in WordPress?

Above the # BEGIN WordPress block; otherwise WordPress rules may run first.

I use Nginx. Will this code work?

No, .htaccess only works on Apache and LiteSpeed. Use the Nginx Redirect Generator.

Related tools