.htaccess Redirect Generator (301, HTTPS, WWW & More)

💻 WEB & DEVELOPER

.htaccess Redirect Generator

Generate correct Apache .htaccess redirect rules — single-page 301s, HTTPS enforcement, www normalization, and trailing slashes — without hand-writing RewriteRule syntax.

[AD SLOT 1 — leaderboard]

🔁Redirect Rule Generator

Choose a redirect type and fill in the details.

Please fill in the required fields.

[AD SLOT 2 — in-content]

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

GoalDirective usedStatus code
Single page redirectRedirect301 (permanent)
Force HTTPSRewriteCond + RewriteRule301
WWW normalizationRewriteCond + RewriteRule301
Whole domain moveRewriteCond + RewriteRule301

← Swipe to see all columns

Worked Example

Force HTTPS

RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
The condition checks if the connection is NOT already HTTPS, then rewrites to the same path under https:// with a permanent (301) redirect.

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.

[AD SLOT 3 — pre-footer]

Frequently Asked Questions

What's the difference between a 301 and 302 redirect?+

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.

Do I need RewriteEngine On for every redirect?+

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.

Why isn't my redirect working?+

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.

Can I combine multiple redirect rules in one .htaccess file?+

Yes, and it's normal to have several. Just put more specific rules above broader ones, since Apache stops at the first match.

Will this redirect affect my SEO?+

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.

Missing info

Please fill in the required fields.

Scroll to Top