Skip to content

.htaccess redirect generator

Pick what you need, force HTTPS, www or non-www, old pages and folders, or a whole-site move, and the generator writes ready .htaccess rules for Apache and LiteSpeed.

www in the address
Page and folder redirects
    .htaccess
    RewriteEngine On

      This tool runs in your browser. We don't store what you type and we use no trackers.

      How to use it and read the results

      How to use the generator

      1. Enter the domain and choose HTTPS and the www style. A site should answer on one address only, such as https://example.com.
      2. Add a redirect for every page or folder whose URL changed. Choose "Folder" to move everything inside it while keeping the rest of the path.
      3. Copy the output and open the .htaccess file in public_html from cPanel's File Manager.
      4. Put the rules at the top, above the # BEGIN WordPress line if there is one, and save.
      5. Test in a private window, or run curl -I http://example.com to see the redirect code and the new address.

      301 or 302?

      A 301 redirect is permanent: search engines move the page's ranking to the new URL, and browsers remember it without asking the server again. A 302 is temporary, right for a maintenance page or a short campaign. Use 302 while testing if you're unsure, then switch to 301.

      Common mistakes

      • An endless redirect loop: usually Cloudflare with Flexible SSL, because the server never sees HTTPS. Tick "behind Cloudflare" or use Full SSL. Details in fixing ERR_TOO_MANY_REDIRECTS.
      • A 500 error after saving: almost always a syntax error. Remove what you added and paste it again exactly as generated. See the 500 error explained.
      • Redirect chains: http to www to https to the new page. The generator folds HTTPS and www into one redirect and, when you enter the domain, sends other redirects straight to the final address.
      • The browser remembers the old redirect: 301s are cached, so always test in a private window.

      For forcing HTTPS step by step with a free SSL certificate, see the force HTTPS guide.

      FAQ

      Where is the .htaccess file in cPanel?

      In public_html. Open File Manager, choose Settings and tick Show Hidden Files, because names starting with a dot are hidden. If it isn't there, create a new file named .htaccess.

      Do these rules work on LiteSpeed?

      Yes. LiteSpeed reads .htaccess and understands the same mod_rewrite rules as Apache. Nginx doesn't read this file and needs a different configuration.

      Does a 301 redirect hurt SEO?

      No, it's the right way to move a page without losing its ranking. Point each old URL at its closest new page and avoid chains of redirects.

      More tools

      Free tools