.htaccess Redirect Generator

Generate correct 301/302 redirect rules for Apache — Redirect directives or RewriteRules, plus HTTPS and www blocks.

This tool runs 100% in your browser. Your data is never uploaded, stored, or logged.

.htaccess rules

  

About this tool

Moving pages without redirects burns SEO and breaks bookmarks. This generator turns a simple old-path new-url list into correct Apache redirect rules — classic Redirect directives or escaped RewriteRule patterns — with optional force-HTTPS and www-normalization blocks.

Every old path is validated so you catch typos before they hit production.

How to use it

  1. List redirects one per line: /old-page /new-page.
  2. Pick 301 (permanent, passes SEO value) or 302 (temporary).
  3. Choose Redirect or RewriteRule style; tick HTTPS/www blocks if needed.
  4. Paste the output at the top of your .htaccess and test.

Useful ways to apply it

  • Redirecting old URLs after a site restructure or migration.
  • Forcing HTTPS across an entire shared-hosting site.
  • Normalizing www vs non-www to a single canonical host.
  • Retiring campaign pages while preserving link equity.

Frequently asked questions

301 or 302 — which should I use?
301 for permanent moves (search engines transfer ranking signals); 302 for temporary situations like A/B tests or maintenance detours.
Redirect vs RewriteRule?
Redirect is simpler and matches path prefixes. RewriteRule uses regex with exact anchoring — the generator escapes special characters and anchors patterns for you.
Where do the rules go?
In the .htaccess file at your document root, ideally near the top. RewriteRule blocks need RewriteEngine On, which the generator includes when required.

Privacy

This tool runs 100% in your browser. Your data is never uploaded, stored, or logged.