.htaccess Redirect Generator

Generate common Apache mod_rewrite snippets for HTTPS upgrades, www canonicalization, single URL moves, and more. Always test on staging — rewrite rules can take down a site if misplaced.

Runs in browser

Redirect recipes you can trust

  • Covers canonical host moves, protocol upgrades, single URL hops, and slash policies.
  • Toggle 301 vs 302 to match permanent migrations or short-lived campaigns.
  • Plain-language explanations accompany every generated snippet.
  • Copy or download the text file for version control friendly hand-offs.

How to deploy safely

  1. Choose the scenario that matches your hosting panel (cPanel, Plesk, bare Apache).
  2. Enter canonical domains or paths — avoid mixing trailing slash styles.
  3. Generate, read the explanation, then paste near the top of .htaccess above fragile rules.
  4. Test with curl -I or browser devtools, watching for loops or double redirects.

Common scenarios

HTTPS cutovers, blog subdomain consolidations, and post-acquisition domain merges all need disciplined redirects. After deployment, confirm TLS with the SSL checker and validate propagation via the DNS checker.

Keep bots aligned after URL changes

Pair redirects with refreshed canonical meta tags so search engines consolidate signals to the final URLs quickly.

Works great with these tools

Redirects to HTTPS only help if the certificate is valid — verify with our free SSL certificate checker.

After changing hosts for a migration, confirm A/AAAA records with our free DNS checker.

Avoid redirect loops on paths meant to stay crawlable — test paths with our free robots.txt generator.

Last updated:

How to use this tool

Apache .htaccess files control redirects at the server edge. Pick a pattern — single URL move, force HTTPS, www canonicalization, trailing slash cleanup, or domain migration — and copy mod_rewrite rules you can paste into .htaccess after testing on staging to avoid redirect loops.

Step 1

Open the .htaccess Redirect Generator and enter the text, URL, file, or settings the tool asks for.

Step 2

Review the options, adjust any settings, and run the tool to generate the result.

Step 3

Check the output, copy or download it if available, and use the related tools below for the next step.

Features

  • Preset patterns for common Apache redirect jobs
  • 301 permanent and 302 temporary options
  • HTTPS, www, and single-URL rewrite snippets
  • Copy-ready .htaccess blocks for developers

Common use cases

  • Create permanent 301 redirects after URL changes
  • Force HTTPS on Apache shared hosting
  • Canonicalize www vs non-www hostnames
  • Plan domain migration and trailing-slash cleanup

Why use this tool?

.htaccess Redirect Generator is built for quick, practical work without making you create an account first. It keeps the interface focused, works on mobile and desktop, and pairs naturally with related ToolsRacks utilities such as Robots.txt Generator & Tester and Meta Tag Generator & Preview.

Frequently asked questions

Common questions people ask before using this tool.

How do I create a 301 redirect in .htaccess?

Choose the single-URL or domain pattern in the generator, enter old and new paths, copy the mod_rewrite block, and add it near the top of your site root .htaccess file on Apache.

Should I use 301 or 302 redirects?

Use 301 for permanent moves so search engines consolidate signals to the new URL. Use 302 only for temporary campaigns or maintenance.

Can redirects affect SEO?

Yes. Clean 301 chains help merge duplicate URLs, preserve backlinks, and avoid soft-404 issues after migrations.

Should I test .htaccess rules before going live?

Always test on staging. A misplaced RewriteRule can cause infinite loops or block important pages.

Other tools from ToolsRacks you might find useful — all free, no signup needed.

Looking for something else? Browse all 27 free tools →