Skip to main content

.htaccess redirect generator: create safe 301 & 302 rules

Generate copy-ready redirect rules for Apache, Nginx, or Cloudflare - single URLs, bulk lists, force-HTTPS, www, and trailing slashes - with built-in loop checks. Free, runs in your browser.

  • No signup required
  • Apache, Nginx & Cloudflare
  • Loop & chain checks
Free SEO toolHow it works

What do you want to redirect?

.htaccess rule

# Enter both the old path and the new URL.

Place this in the .htaccess file at your site root, above any existing rules. Test before and after with our redirect checker.

Planning a site migration?

We map and test every redirect so you keep your rankings and your visitors never hit a dead link.

Talk to an engineer about this

A redirect sends visitors and search engines from an old URL to a new one. Get the rule right and you keep your rankings; get it wrong and you create loops, lose link equity, or break your site.

This generator writes correct, copy-ready redirect rules for Apache, Nginx, and Cloudflare - so you never have to hand-write mod_rewrite syntax again.

What this tool generates

Single & bulk redirects

One old → new pair, or paste a whole migration map at once.

Force HTTPS

Redirect every HTTP request to its secure HTTPS version.

www canonicalization

Force www → non-www (or the reverse) to avoid duplicate content.

Trailing slashes

Add or remove trailing slashes consistently across the site.

How to create and install a redirect

  1. Pick a scenario - single, bulk, force-HTTPS, www, or trailing slash.
  2. Enter your URLs and choose your server (Apache, Nginx, or Cloudflare) and redirect type.
  3. Copy the rule the tool generates.
  4. Install and test - add it to .htaccess or your server block, then confirm it resolves in a single hop.

Which redirect status code should you use?

HTTP redirect status codes and when to use each
CodeMeaningPasses SEO?Use it for
301PermanentYesMigrations, renamed/moved pages (~95% of cases)
302TemporaryNo (keeps old URL)Maintenance, A/B tests, short-term moves
307Temporary, method-preservingNoAPIs/forms where POST must stay POST
308Permanent, method-preservingYesPermanent API/form moves

For the official reference, see MDN's guide to HTTP redirections.

Avoiding loops and chains

A redirect loop happens when a URL redirects to itself or back through a cycle - the browser gives up with a "too many redirects" error.

A redirect chain is A→B→C: every extra hop slows the page, wastes crawl budget, and dilutes link equity.

The rules: never point a URL at itself, always redirect straight to the final destination, and delete old rules when you restructure. This generator flags identical source/destination pairs and duplicate sources before you ship them.

Redirects and SEO during a migration

When you change URLs, a clean 301 from every old URL to its closest new equivalent is what carries your rankings across.

Skipping redirects creates 404s that drop out of the index; redirecting everything to the homepage is treated as a soft 404 and loses the page's value.

Map each old URL to a relevant new one, redirect in a single hop, then re-test. After deploying, verify your rules with the redirect & HTTP status checker.

Related technical-SEO tools

FAQ

Your questions, answered

Have a question about your project? Ask us on a free call, and we'll give you a straight answer.

What is an .htaccess redirect generator?
It's a free tool that writes the redirect rules for your web server so you don't have to memorize Apache mod_rewrite syntax. Enter your old and new URLs (or pick a scenario like force-HTTPS or www canonicalization) and it generates copy-ready rules for Apache (.htaccess), Nginx, or Cloudflare, using the redirect status code you choose.
What is the difference between a 301 and 302 redirect?
A 301 is a permanent redirect: it tells search engines the page has moved for good and transfers almost all ranking signals (link equity) to the new URL. A 302 is temporary and does not pass ranking signals the same way. Use 301 for permanent moves and migrations (about 95% of cases) and 302 only for temporary situations like maintenance or A/B tests.
When should I use a 307 or 308 redirect?
307 (temporary) and 308 (permanent) are the method-preserving versions of 302 and 301. Unlike 301/302, they guarantee the HTTP method is preserved - a POST stays a POST. Use 307/308 for API endpoints and forms where the request method must not change. For ordinary page redirects, 301 is still the standard.
Where do I put the .htaccess redirect code?
Add it to the .htaccess file in your website's root directory (the same folder as your homepage), placing redirect rules near the top, before other rewrite rules. .htaccess works on Apache servers (and LiteSpeed). On Nginx you edit the server block instead, and on Cloudflare you create a Redirect Rule in the dashboard - this tool generates all three.
How do I redirect HTTP to HTTPS?
Choose the 'Force HTTPS' scenario. On Apache it adds a RewriteCond/RewriteRule that redirects any HTTP request to the HTTPS version of the same URL with a 301. On Cloudflare you simply enable 'Always Use HTTPS' - no rule needed. Always use a 301 for HTTP-to-HTTPS so the secure URL is treated as canonical.
How do I avoid redirect loops and chains?
A loop happens when a URL redirects to itself (directly or via a cycle); a chain is A→B→C, which wastes crawl budget and slows users. Never redirect a URL to itself, always point redirects straight to the final destination, and remove old rules during a migration. This tool warns you when a source and destination match or when a source URL is duplicated.
Do redirects affect SEO?
Yes. Correct 301 redirects preserve the ranking signals of your old URLs when you change them, which is essential during a site migration or URL restructure. Broken or missing redirects create 404s that lose rankings and traffic, while long redirect chains slow crawling and page load. Mapping redirects carefully is one of the highest-impact parts of any migration.
Is this redirect generator free?
Yes, completely free with no signup. It runs entirely in your browser - nothing you enter is sent to a server - so you can generate as many rules as you like.
301 vs 302?
301 is permanent and passes ranking signals; 302 is temporary and doesn't. Use 301 for migrations, 302 only for short-term moves.
When do I use 307 or 308?
They preserve the HTTP method (a POST stays a POST). Use them for APIs and forms; 301 remains standard for pages.
Where does the code go?
In the .htaccess file at your site root (Apache), the server block (Nginx), or a Redirect Rule in the Cloudflare dashboard.
Is it free?
Yes - free, no signup, and it runs entirely in your browser.

Tell us about your project

Tell us what you're building, when you need it, and what's in the way. A senior engineer will reply within one business day with honest next steps, even if that means we're not the right fit.

  • Your project is led by a senior engineer, not a junior and not AI on its own
  • AI speeds up the build. Every change is reviewed and tested before it ships
  • Best for MVPs, SaaS products, automation, and fixing apps that keep breaking
Browse all SEO tools