How it works
- Configure the redirects you need — HTTPS, WWW preference, or specific old-to-new URL pairs.
- Enter your domain and any source/target paths.
- Generate the rule block and copy it.
- Paste it into the
.htaccessfile in your site's root and save.
What it generates
- HTTP → HTTPS redirect — force every request onto the secure version of your site.
- WWW ↔ non-WWW — canonicalize to either
www.or the bare domain. - 301 page redirects — permanently point an old URL to a new one.
- RewriteEngine setup — the required
RewriteEngine Onand condition lines. - Correct flags —
[R=301,L]so redirects are permanent and processing stops cleanly. - Copy-ready block — properly ordered rules with no missing escapes.
Common use cases
- HTTPS migration — send all traffic to the secure URL after installing an SSL certificate.
- Choosing a canonical host — avoid splitting authority between WWW and non-WWW.
- Moving a page — preserve rankings when a URL changes by redirecting it with a 301.
- Site restructure — map a batch of old paths to their new locations.
Example
To force HTTPS, the tool outputs a block such as RewriteEngine On — paste it at the top of your
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L].htaccess and every request is upgraded to HTTPS.
Frequently asked questions
Is the .htaccess Redirect Generator free?
Yes — completely free, with no signup. It runs in your browser and never stores what you enter.
Will this work on every server?
These rules are for Apache with mod_rewrite enabled (the most common shared-hosting setup). Nginx and IIS use different syntax. After deploying, confirm the hops with the Redirect & HTTP Status Checker and verify your certificate with the SSL Certificate Checker.
Should I use 301 or 302?
Use a 301 for permanent moves so link equity transfers; use a 302 only for temporary changes. Our 301 vs 302 redirects guide explains when to use each, and the HTTPS migration guide covers the full HTTPS switch.