.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.
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 engineerA 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
- Pick a scenario - single, bulk, force-HTTPS, www, or trailing slash.
- Enter your URLs and choose your server (Apache, Nginx, or Cloudflare) and redirect type.
- Copy the rule the tool generates.
- Install and test - add it to
.htaccessor your server block, then confirm it resolves in a single hop.
Which redirect status code should you use?
| Code | Meaning | Passes SEO? | Use it for |
|---|---|---|---|
| 301 | Permanent | Yes | Migrations, renamed/moved pages (~95% of cases) |
| 302 | Temporary | No (keeps old URL) | Maintenance, A/B tests, short-term moves |
| 307 | Temporary, method-preserving | No | APIs/forms where POST must stay POST |
| 308 | Permanent, method-preserving | Yes | Permanent 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
- Redirect & HTTP status checker - trace your redirect chains and confirm a single-hop 301.
- DNS lookup - verify your records before and after a move.
- Broken link checker - find the dead links your redirects should fix.
- Website launch checklist - everything to verify before going live.
Related free tools
Keep going with these tools
DNS Lookup & Checker
Check any domain's DNS records instantly
Domain Age & WHOIS Checker
How old is any domain?
Website Down Checker
Is it down for everyone, or just you?
Redirect & HTTP Status Checker
Trace 301/302 redirect chains
Cron Expression Generator
Build, decode & preview cron schedules
Schema Markup Generator
Create valid JSON-LD structured data
Want a team to handle it for you? We design and build fast, SEO-ready websites that convert. Explore AI web development.
Related guides
Go deeper with our guides
Practical, up-to-date guides on the strategy, costs, and execution behind this tool.
Technical SEO Checklist for Small Business Websites in 2026
Fix the technical SEO issues holding your site back: crawlability, indexation, site speed, and schema markup.
Website Redesign for Small Businesses in 2026: When, Why, and How
Plan a redesign: diagnose problems, preserve SEO, budget correctly, and execute without losing leads or rankings.
Small Business SEO Guide 2026: Strategy and Execution
An SEO framework for small businesses in 2026, from technical foundations and content planning to local visibility and tracking.
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.
