Free .htaccess Redirect Generator
Generate Apache .htaccess 301 and 302 redirect rules from old URL to new. Single redirects, force-HTTPS, and www canonicalization with correct syntax. Free, copy-paste, no signup.
# Redirects generated by U2L AI (u2l.ai/tools/htaccess-redirect-generator) # Path redirects Redirect 301 /old-page /new-page
Add to the .htaccess file in your site root. Place canonicalization rules before path redirects. Back up your existing .htaccess first.
Quick Answer
An .htaccess redirect generator builds the Apache directives that send visitors from an old URL to a new one. Add your source and destination paths, choose 301 (permanent) or 302 (temporary), and optionally force HTTPS or www, and the tool outputs ready-to-paste .htaccess rules. The U2L .htaccess Redirect Generator runs in your browser. Free, no signup.
Quick Facts
- .htaccess is Apache's per-directory config file; redirects placed in the site-root .htaccess apply to the whole site.
- 301 is a permanent redirect (passes SEO value, cached by browsers); 302 is temporary (no caching, no SEO transfer).
- Simple path redirects use the Redirect directive: Redirect 301 /old https://example.com/new.
- Force-HTTPS and www/non-www canonicalization use mod_rewrite (RewriteCond + RewriteRule).
- Order matters: put canonicalization (HTTPS, www) rules before individual path redirects.
- Only Apache reads .htaccess - Nginx and others use different syntax. Confirm your server runs Apache.
- Browser-only and instant - rules are built locally and never sent to U2L servers.
How to generate .htaccess redirects
Add redirects, pick options, copy the rules.
- 1
Add your redirects
Enter each old path and the new destination (a path or a full URL). Add as many rows as you need with the Add redirect button.
- 2
Choose 301 or 302 and canonicalization
Pick a permanent 301 or temporary 302, then optionally enable force-HTTPS and www or non-www canonicalization with your domain.
- 3
Copy into your .htaccess
Copy the generated rules and paste them into the .htaccess file in your site root. Back up the existing file first and test a couple of URLs.
What is a .htaccess Redirect Generator?
.htaccess Redirect Generator is a tool that builds Apache .htaccess redirect rules from a simple form. You enter old and new URLs, choose the redirect type, and the generator produces the correct Redirect and mod_rewrite directives - so you do not have to remember Apache's syntax or risk a typo that takes your site down.
.htaccess is a configuration file that Apache reads on every request for the directory it sits in. Placed at your site root, it can rewrite and redirect URLs, force HTTPS, canonicalize the www prefix, set headers, and more. Redirects are its most common use: telling browsers and search engines that a URL has moved.
Getting redirect syntax right matters because the cost of a mistake is high. A misplaced rule can create a redirect loop, a 500 error, or silently send visitors to the wrong page - and because .htaccess is read on every request, a broken file can take the whole site offline. A generator produces known-good syntax and the correct directive for each job.
Developers, SEOs, and site owners use this when migrating URLs, consolidating www and HTTPS variants, retiring old pages, or restructuring a site - any time content moves and the old links must keep working.
How does a .htaccess Redirect Generator work?
For each path redirect you add, the generator emits a Redirect directive: Redirect 301 /old-page https://example.com/new-page. The first argument is the status code, the second is the source path on your domain, and the third is the destination, which can be a path or an absolute URL. Apache matches the source against incoming requests and responds with the redirect.
For canonicalization, the tool switches to mod_rewrite, which is more flexible than the basic Redirect directive. Force-HTTPS adds a RewriteCond that checks whether the connection is not secure, then a RewriteRule that sends the request to the https version of the same host and path. The www rules check the host against your domain and redirect to the canonical (www or non-www) form.
The output is ordered deliberately: canonicalization rules (HTTPS, www) go first inside an <IfModule mod_rewrite.c> guard, and individual path redirects follow. This ordering matters because you want a request normalized to its canonical host and scheme before path-level redirects evaluate, avoiding double redirects and loops.
Everything is computed in your browser; nothing is sent to U2L. The result is standard Apache syntax you paste into .htaccess. Because a broken .htaccess can return a 500 across your site, always back up the current file first and test a handful of URLs after deploying - the generator gives you correct syntax, but you still control placement and your server's module availability.
Use Cases
How marketers, businesses, and developers use .htaccess redirect generator.
Redirecting moved or renamed pages
When a page's URL changes, a 301 keeps old links and search rankings working by sending visitors and crawlers to the new address.
Forcing HTTPS across the site
Redirect all http traffic to https with a single mod_rewrite rule so every visitor gets the secure version and you avoid duplicate-content issues.
Canonicalizing www vs non-www
Pick one canonical host and redirect the other, consolidating SEO signals and preventing the same content from ranking under two hostnames.
Site migrations and restructures
Map an entire batch of old URLs to their new locations during a redesign so no inbound link or bookmark breaks after launch.
Retiring old content gracefully
Send visitors from a discontinued product or article to the most relevant replacement instead of a dead 404 that loses the visit.
Consolidating duplicate URLs
Redirect trailing-slash, index.html, or legacy variants to a single canonical URL to clean up crawl budget and analytics.
Temporary redirects for promotions
Use a 302 to point a campaign path at a seasonal landing page, then remove it later without the redirect being cached permanently.
Fixing SEO duplicate-content penalties
Resolve http/https and www/non-www splits that dilute rankings by enforcing one canonical version of every URL.
Learning Apache redirect syntax
See how form inputs translate into Redirect and RewriteRule directives, building a working mental model of mod_rewrite.
.htaccess Redirect Generator vs Alternatives
Side-by-side feature and pricing comparison with the top alternatives.
| Feature | U2L | Manual editing | Hosting panel | Plugin |
|---|---|---|---|---|
| Free, no signup | Varies | Varies | ||
| Correct 301/302 syntax guaranteed | ||||
| Force HTTPS + www rules | Manual | Sometimes | Sometimes | |
| Works without a CMS | ||||
| No server load from a plugin | ||||
| Browser-only (no data sent) |
.htaccess Redirect Generator vs Editing .htaccess by hand
Experienced developers edit .htaccess directly. It is fast and needs no tool once the directive syntax and mod_rewrite flags are second nature.
The risk is real: a single misplaced flag or condition can cause a redirect loop or a site-wide 500. The generator emits known-good syntax and orders canonicalization before path rules, removing the most common ways hand-edited redirects break.
.htaccess Redirect Generator vs A WordPress redirect plugin
Plugins like Redirection manage redirects inside WordPress with a friendly UI, which is convenient when your whole site is WordPress.
Plugins add PHP overhead on every request and only work within the CMS. Native .htaccess rules run at the server level - faster and applicable to any Apache site, CMS or not. This generator gives you those native rules without installing anything.
Best Practices
Back up .htaccess before editing
Because a broken .htaccess can 500 the whole site, save a copy of the current file so you can restore instantly if something goes wrong.
Use 301 for permanent moves
A 301 passes SEO value to the new URL and is cached by browsers. Reserve 302 for genuinely temporary redirects you intend to remove.
Put canonicalization before path redirects
Force HTTPS and www rules should run first so requests are normalized before path-level redirects evaluate, avoiding double redirects and loops.
Test for redirect loops
After deploying, load redirected URLs and confirm they resolve in one hop. A rule that redirects a page to itself creates an infinite loop.
Avoid chains of redirects
Redirect old URLs straight to the final destination, not through intermediate URLs. Each extra hop slows the page and dilutes SEO value.
Confirm mod_rewrite is enabled
The HTTPS and www rules need mod_rewrite. Most hosts enable it, but verify - the <IfModule> guard prevents errors if it is missing.
Keep redirects in the root .htaccess
Site-wide redirects belong in the root file. Per-directory .htaccess files only affect their own folder, which can cause confusing partial behavior.
Document each redirect with a comment
Add a short comment above non-obvious rules so future maintainers know why a redirect exists and can safely remove it later.
Common Mistakes to Avoid
Creating a redirect loop
Redirecting a URL to itself, or A to B and B back to A, sends browsers into an infinite loop. Always redirect toward the final destination only.
Using 302 for permanent moves
A temporary 302 does not pass SEO value and is not cached, so search engines keep the old URL indexed. Use 301 for moves that are permanent.
Wrong rule order causing double redirects
Placing path redirects before HTTPS/www canonicalization makes a request redirect twice. Put canonicalization first to normalize the request once.
Editing without a backup
A syntax error in .htaccess can take the entire site down with a 500 error. Skipping the backup turns a small typo into an outage.
Assuming .htaccess works on Nginx
.htaccess is Apache-only. On Nginx the file is ignored entirely; you need server-block directives instead. Confirm your server before relying on it.
Forgetting RewriteEngine On
mod_rewrite rules do nothing without RewriteEngine On. The generator includes it, but hand-written rules often omit it and silently fail.
Technical Specifications
| File | .htaccess in the site root (Apache) |
| Path redirect directive | Redirect 301|302 /source destination |
| Canonicalization | mod_rewrite (RewriteCond + RewriteRule) |
| 301 | Permanent - passes SEO value, browser-cached |
| 302 | Temporary - no SEO transfer, not cached |
| Required module | mod_rewrite (for HTTPS/www rules) |
| Rule order | Canonicalization first, then path redirects |
| Privacy | Built in your browser. No data sent to U2L. |
Frequently Asked Questions
What is an .htaccess redirect?
What is the difference between a 301 and a 302 redirect?
How do I redirect a single page in .htaccess?
How do I force HTTPS with .htaccess?
How do I redirect non-www to www (or the reverse)?
Where do I put the redirect rules?
Why did my site break after editing .htaccess?
Does .htaccess work on Nginx?
How do I avoid redirect loops?
Can I redirect a whole folder or pattern?
Do redirects affect SEO?
What is mod_rewrite?
Can the destination be a full URL on another domain?
Should I redirect http and www in the same file?
Is this generator free and private?
How do I test that a redirect works?
Related Free Tools
Whois Lookup
Look up registrar, owner, creation date, expiry, and DNS for any domain. Free Whois data, no API key.
Free QR Code API
REST API for generating SVG and GIF QR codes. WiFi, vCard, URL, and text. Free, no API key, edge-cached.
DNS / CNAME Checker
Look up A, AAAA, CNAME, MX, TXT, NS records for any domain. Verify global DNS propagation in seconds.
SSL Certificate Checker
Inspect any SSL certificate: validity, issuer, chain, expiry, and protocol. Spot issues before users do.
HTTP Header Inspector
Inspect HTTP request and response headers for any URL. Cache, security, CORS, and server details.
URL Shortener Speed Test
Compare redirect response times across 10+ URL shorteners. Real measurements in your browser.
Key Terms
- .htaccess
- Apache's per-directory configuration file. Placed at the site root, it can redirect URLs, force HTTPS, set headers, and more, and is read on every request.
- 301 redirect
- A permanent redirect status code that passes SEO value to the destination and is cached by browsers.
- 302 redirect
- A temporary redirect status code that does not transfer SEO value and is not cached, so the original URL stays indexed.
- mod_rewrite
- The Apache module providing rule-based URL rewriting and conditional redirects, used for force-HTTPS and www canonicalization.
- Canonicalization
- Enforcing a single preferred URL form (one scheme, one host) by redirecting the alternatives, consolidating SEO signals.
Need redirects without touching server config?
U2L lets you create and edit redirects as branded short links - no .htaccess, no deploy, full click analytics, and editable destinations any time. Sign up free to manage redirects the easy way.
Sign up free