Htaccess Redirect Generator

Generate .htaccess redirect rules for 301 and 302 redirects, www or non-www, and HTTPS, then paste them into your Apache config.

Adding redirect rules to .htaccess

On Apache servers, the .htaccess file's Redirect directive sends visitors - and search engines - from an old URL straight to a new one. Add each old-path/new-path pair below, choose 301 (permanent) or 302 (temporary), and paste the generated lines directly into your site's .htaccess file, placed above any existing RewriteRule block.

301 vs. 302: why the choice actually matters

A 301 tells browsers and search engines the move is permanent, which causes search engines to transfer the old page's accumulated ranking signals and link equity over to the new URL - this is the right choice for a page that has genuinely moved for good, such as during a site restructure or URL-slug change. A 302 signals a temporary move instead; search engines generally keep the old URL indexed rather than transferring its signals, which is correct behavior for something like a short-term maintenance redirect, but the wrong choice if the move is actually permanent.

Why placement in the file matters

Apache processes directives from different modules - mod_alias (which provides the simple Redirect directive this tool generates) and mod_rewrite (which provides RewriteRule) - and these can conflict or produce unexpected results if ordered incorrectly. Placing simple Redirect directives near the top of the file, before any RewriteEngine/RewriteRule block, avoids that class of problem.

Common reasons to set up a redirect

A page or post has been renamed or moved to a new URL slug, an entire site has migrated to a new domain or URL structure, or an old URL has started returning a 404 that still receives real search traffic or backlinks you don't want to lose - in every one of these cases, a 301 redirect preserves that traffic and ranking value instead of letting it go to a dead end.

Redirect rules without guesswork

On Apache servers the .htaccess file controls redirects, and a single typing mistake can take a site offline. This tool writes the rules for you for common cases such as 301 redirects, forcing HTTPS and choosing www or non-www.

Use it safely

Copy your existing .htaccess before changing it, add rules one at a time and test several URLs after each change. Keep the rules in a sensible order, as the first matching rule usually wins.

Know your server

These rules work on Apache and compatible servers. Nginx uses a different configuration format, and some hosts manage redirects in their control panel, so check how your hosting works first.

Common rules

A permanent redirect from an old page can be written Redirect 301 /old-page https://example.com/new-page. To force HTTPS use RewriteEngine On, RewriteCond %{HTTPS} off and a RewriteRule that sends visitors to the secure version. Always use 301 for permanent moves so link value passes.

Safe editing

Back up .htaccess, test one change at a time, avoid redirect loops and check the result with a redirect checker. A syntax error can take the site down, so keep FTP or file manager access ready.

Frequently asked questions

Should I use 301 or 302?

Use 301 for permanent moves - it tells search engines to transfer the old page's ranking signals to the new URL. Use 302 only for genuinely temporary redirects, since search engines treat it as non-permanent and may keep indexing the old URL.

Where exactly do these lines go in my .htaccess file?

Place simple Redirect directives near the top of the file, before any RewriteEngine/RewriteRule block - mod_alias (Redirect) and mod_rewrite rules can conflict if ordered incorrectly.

Can I generate redirects for more than one page at a time?

Yes - click "+ Add redirect" to add as many old-path/new-path rows as you need, and the tool generates one Redirect line per completed row in a single batch.

Does a 301 redirect actually transfer my old page's SEO ranking?

It transfers most of the accumulated ranking signal over time, though search engines typically take some time to fully recognize and process the redirect - it's the standard, recommended way to preserve SEO value when a URL changes permanently.

What happens if I only fill in the old path but not the new one for a row?

That row is skipped when generating the rules - only rows with both an old path and a new path filled in produce a Redirect line in the output.

Does Nginx use .htaccess?

No. Nginx has its own configuration files.

Why do I get a 500 error after editing?

A syntax mistake. Restore your backup and try the rule again.

More in Technical SEO & Site Management