.htaccess Redirect Generator

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

Tool input is processed locally in your browser and is not submitted to CodeNimbleTools. Avoid pasting production secrets into any device or website you do not fully trust.

.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.

Worked example

Example input

/old-page /new-page

Expected output

A permanent redirect rule from /old-page to /new-page

Edge cases to check

  • RewriteRule patterns are relative to directory context.
  • Rule order can create loops or shadow later rules.
  • Apache modules and host configuration may differ.

Known limitations

Generated rules must be tested on staging and backed up before deployment. Syntax-valid rules can still redirect the wrong traffic.

How this tool was reviewed

Reviewed with path redirects, absolute targets, HTTPS and host canonicalization examples.

Last reviewed: September 3, 2026 · Maintainer: William

Standards and technical references

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

Tool input is processed locally in your browser and is not submitted to CodeNimbleTools. Avoid pasting production secrets into any device or website you do not fully trust.