VSM
VSM

.htaccess Redirect Generator

Generate redirect rules for Apache .htaccess

Generated .htaccess Code

Redirect 301 /old-page /new-page

.htaccess Redirect Generator — Instant Rules

The .htaccess redirect generator builds precise Apache redirect rules for you in seconds — covering permanent 301 redirects, temporary 302s, full-domain moves, and wildcard pattern-based rewrites, all without touching a single line of mod_rewrite syntax by hand.

Benefits of the .htaccess redirect generator

  • Produces error-free .htaccess code instantly — no more typos in RewriteRule flags or forgotten RewriteEngine On directives.
  • Covers every common redirect type: 301 Permanent, 302 Found, 307 Temporary, and HTML meta refresh in one unified interface.
  • Supports wildcard and regex patterns so you can redirect entire directory structures with a single rule instead of dozens of individual lines.
  • Protects your SEO equity during site migrations, URL restructures, or HTTPS upgrades by generating correct 301 directives that pass full link value.
  • Completely free and instant — the output is ready to paste directly into your .htaccess file on any Apache or LiteSpeed server.

Use cases for .htaccess redirects

  • Domain migrations — forward every URL from an old domain to a new one while preserving search rankings accumulated over years.
  • Enforcing HTTPS and canonical www/non-www preferences so Google indexes only one version of your URLs.
  • Recovering from 404 errors after a CMS restructure — redirect deleted or renamed pages to relevant replacements before rankings drop.
  • Redirecting an entire legacy directory to a new URL structure using one wildcard rule, saving hours of manual work.
  • Creating vanity or campaign URLs that silently forward visitors to long landing-page addresses without a plugin.

How to use the .htaccess redirect generator

  1. Select your redirect type — choose 301 for permanent SEO-safe moves, 302 for temporary redirects, or wildcard/regex for pattern-based rules.
  2. Enter the source URL or pattern (the old path) and the destination URL (the new path or domain) in the respective fields.
  3. Click Generate to get the complete .htaccess snippet, including the RewriteEngine On directive and any necessary RewriteCond conditions.
  4. Copy the output and paste it at the top of your .htaccess file on the server, then verify the redirect works using your browser or an HTTP header checker.

Frequently asked questions

When should I use a 301 instead of a 302? Use a 301 Moved Permanently whenever a page has moved for good — Google will transfer ranking signals to the new URL. Use 302 only for genuinely temporary redirects where you intend to restore the original URL later.

Will this code work on LiteSpeed servers? Yes. LiteSpeed is fully compatible with Apache .htaccess syntax, including mod_rewrite directives, so the generated rules work on shared hosting, cPanel environments, and dedicated LiteSpeed servers without modification.

Can I redirect an entire folder with one rule? Absolutely. Select the wildcard or regex mode, enter a pattern like /old-section/(.*)$ as the source, and the tool generates a RewriteRule with the correct $1 back-reference to carry the remaining path to the new destination.

Where do I place the .htaccess file? The .htaccess file lives in your website root — typically public_html or www on shared hosting. If the file does not exist yet, create it with exactly the name .htaccess (leading dot, no extension) and paste the generated code at the top.