Skip to main content
Free Tools

.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 requiredApache, Nginx & CloudflareLoop & chain checks

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.

Bring this result to an engineer

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.

Frequently asked questions

What is an .htaccess redirect generator?
A free tool that writes redirect rules for Apache, Nginx, or Cloudflare from your old/new URLs, so you don't hand-write mod_rewrite.
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.
How do I redirect HTTP to HTTPS?
Use the Force HTTPS scenario, or enable "Always Use HTTPS" on Cloudflare. Always use a 301.
How do I avoid loops and chains?
Never redirect a URL to itself, point straight to the final destination, and remove old rules. The tool warns about loops and duplicates.
Do redirects affect SEO?
Yes - correct 301s preserve rankings during URL changes; broken or chained redirects lose traffic and slow crawling.
Is it free?
Yes - free, no signup, and it runs entirely in your browser.

Related technical-SEO tools

Launch Faster

Ready to ship your next product?

Tell us what you're building. Senior engineers will scope, plan, and start delivering your product with production-ready architecture - fast.

Talk to real engineers
Clear scope in one call
No obligation