.htaccess Redirect Generator
Generate correct Apache .htaccess redirect rules — single-page 301s, HTTPS enforcement, www normalization, and trailing slashes — without hand-writing RewriteRule syntax.
Redirect Rule Generator
Choose a redirect type and fill in the details.
Why .htaccess Redirects Are Easy to Get Wrong
✓ Apache mod_rewrite and Redirect directive syntax checked against current Apache HTTP Server documentation — last checked June 2026.
Apache's .htaccess file gives you two main ways to redirect: the simple Redirect directive (from mod_alias) for straightforward path-to-path redirects, and the RewriteEngine / RewriteCond / RewriteRule trio (from mod_rewrite) for anything involving conditions, like checking the current host or protocol before redirecting. Mixing up when to use which — or forgetting RewriteEngine On before any RewriteRule — is the single most common reason a redirect "doesn't work." Apache's own rewrite documentation is thorough but dense; it's written for people who already know mod_rewrite's mental model, which makes it a rough starting point if you're hand-writing your first rule.
The other classic mistake is redirect order. Apache reads .htaccess top to bottom and stops at the first matching rule, so a broad domain-wide redirect placed above a specific page redirect will swallow it before it ever runs. Always put your most specific rules first. A closely related trap is the redirect loop: if your HTTPS-forcing rule and your www-normalizing rule both fire on every request without checking each other's conditions properly, you can end up bouncing a visitor's browser between two URLs until it gives up with a "too many redirects" error — always test a fresh rule in an incognito window before trusting it's actually fixed.
Redirect Type Reference
| Goal | Directive used | Status code |
|---|---|---|
| Single page redirect | Redirect | 301 (permanent) |
| Force HTTPS | RewriteCond + RewriteRule | 301 |
| WWW normalization | RewriteCond + RewriteRule | 301 |
| Whole domain move | RewriteCond + RewriteRule | 301 |
← Swipe to see all columns
Worked Example
Force HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]A 301 status code tells browsers and search engines the move is permanent, which is almost always what you want for SEO — it passes link authority to the new URL and gets search engines to update their index rather than keep crawling the old one. Use 302 only for genuinely temporary redirects. Apache's own guide to redirecting and remapping with mod_rewrite covers more advanced cases than this generator handles, like redirecting based on query strings or user agents. Once your redirects are live, double-check there's no redirect chain (A→B→C) slowing things down — each hop adds latency and dilutes SEO value slightly. For testing the resulting URLs, our URL Encoder can help when paths contain special characters.
Frequently Asked Questions
A 301 redirect is permanent and tells search engines to transfer SEO value to the new URL. A 302 redirect is temporary and signals that the original URL should remain indexed, since the move isn't expected to last.
Only if you're using RewriteRule (mod_rewrite). Simple Redirect directives from mod_alias don't need it, but it's harmless to include if your .htaccess already uses both.
Common causes include rule order (a broader rule above matching first), a missing RewriteEngine On line, browser caching of an old redirect, or mod_rewrite not being enabled on the server. Test in an incognito window to rule out caching.
Yes, and it's normal to have several. Just put more specific rules above broader ones, since Apache stops at the first match.
A correctly implemented 301 redirect passes the vast majority of the old page's SEO value to the new URL over time. Redirect chains (multiple hops) and 302s used where 301s were needed are the main ways redirects hurt SEO instead of helping it.
Explore All NerdyTools By Categories
Find the right tool for any task — free, fast, and no sign-up required
