Skip to tool

HTACCESS Redirect Generator

Build Apache redirect rules for HTTPS, a canonical www or non-www hostname, legacy paths, wildcard redirects, and trailing slashes. Everything runs in your browser.

Redirect settings

Choose the rules you need. The output updates as you type.

HTTPS and canonical hostname

Enter only the hostname, without https:// or a path. Use www.example.com for Add WWW, or example.com for Remove WWW.

Legacy path redirects

Use * in the old path to capture a value and $1 in the destination to reuse it. Use 301 for permanent moves and 302 for temporary ones.

Trailing slashes

Existing files and directories are skipped. This option is intended for clean URL structures.

Choose at least one redirect rule to generate an .htaccess snippet.

Errors

    Warnings

      Back up first. Apache redirect mistakes can take a site offline. Save your current .htaccess file, review the generated rules on a staging site, and keep the WordPress block intact if you use WordPress.

      Generated .htaccess rules

      Paste this snippet above the WordPress block in your .htaccess file.

      0 rules
      
                  

      No rules generated yet.

      How the generator works

      • Source paths are matched without the leading slash inside RewriteRule, as Apache expects.
      • Wildcards become numbered captures. A source such as /old/* can redirect to /new/$1.
      • Redirect loops, duplicate sources, unsafe protocols, and invalid destinations are blocked.
      • Query strings are preserved by default and can be dropped for the custom rules.
      • Existing files and directories are skipped by trailing-slash normalization.

      Private by design: no URL, hostname, or redirect rule is uploaded. The generator runs entirely in your browser.

      Before you edit .htaccess

      Download a copy of the current file before making changes. If you use WordPress, place the generated rules above the # BEGIN WordPress line and leave the existing WordPress block intact. After uploading the file, test the old URLs, the canonical hostname, and a few normal pages. If something breaks, restore your backup immediately.

      HTTPS, www, and redirect status codes

      A 301 redirect tells browsers and search engines that a move is permanent. A 302 redirect is temporary. Use 301 for a lasting HTTPS or hostname change and 302 only while testing or during a short-lived campaign. If a proxy or CDN terminates HTTPS before Apache, the %{HTTPS} variable may need to be adjusted for your hosting environment.

      Common mistakes to avoid

      Related tools