.htaccess Redirect Generator
Emit paste-ready Apache redirect rules for moved pages plus optional HTTPS and www canonicalization.
Generate Apache .htaccess redirect rules instantly. Free online redirect generator for 301/302 redirects, HTTPS and www canonicalization.
Calculator Inputs
About Redirect Rules
Emit paste-ready Apache redirect rules for moved pages plus optional HTTPS and www canonicalization.
Moving a page without a redirect strands its rankings and breaks bookmarks. This generator writes the exact Apache directives: a 301 (permanent, transfers ranking signals) or 302 (temporary) line, plus optional canonical blocks that force HTTPS and a single www form.
Paste the output near the top of your .htaccess, test with curl or a redirect checker, and keep old rules for at least a year. Everything is generated locally in your browser.
Where it is used
Site migrations, HTTP→HTTPS moves, www consolidation, and retiring old URLs without losing rankings.
How to use the Redirect Rules
- Old Path (e.g. /old-page) — enter the value (e.g. /old-page).
- New URL (e.g. https://example.com/new-page) — enter the value (e.g. https://example.com/new-page).
- Redirect Type — enter the value.
- Also add force-HTTPS block — enter the value.
- Also add non-www → www block — enter the value.
- Calculate — press the Calculate button to see the result instantly above.
Formula
Redirect <code> <old> <new> + optional HTTPS/www RewriteCond blocks.
Examples
Example
Frequently Asked Questions
- 301 or 302 — which should I use?
- 301 for permanent moves (passes most ranking signals); 302 only when the move is genuinely temporary, like maintenance or A/B tests.
- Where in .htaccess do redirects go?
- Near the top, before CMS rewrite blocks (e.g. WordPress rules), so they execute first. Always back the file up before editing.
- Why both HTTPS and www rules?
- Each creates a duplicate version of every URL. Canonicalizing to one form concentrates ranking signals and avoids duplicate-content issues.