Skip to main content

301 Redirect Generator

Turn a list of old → new URLs into ready-to-deploy redirect rules for Apache (.htaccess), Nginx, IIS, Cloudflare, Netlify, or CSV — with chain detection, www/HTTPS canonicalization, and regex rules. Everything runs in your browser.

Looking for something else?
  • Want to check whether a redirect already works on a live site? That needs a live HTTP header lookup (a redirect checker), which this page does not do. This tool generates redirect rules you deploy on your own server; use the curl command in the tips section to verify them after deployment.
  • Running WordPress and want redirects managed in the dashboard? Use a redirection plugin on your own install. This generator produces the raw server rules so you are never locked into a plugin.

Bulk redirect generator

Paste old → new pairs, one per line. Separators: comma, tab, ->, |, or spaces. Full URLs are fine — sources are trimmed to paths automatically. Or upload a CSV with two columns.


Test after deploying

curl never caches — your browser does. Run this against the first URL:


www / HTTPS canonicalizer

One canonical host, one scheme. Generates the force-HTTPS and www rules for Apache and Nginx.

force HTTPS

Apache .htaccess


Nginx


Regex redirect rule

One rule for hundreds of URLs. Anchors ^…$ are added automatically. Use $1–$9 in the target for capture groups.



Redirect chain validator

Paste your redirect map. The validator flags chains (/a → /b → /c), loops, and duplicate sources before you deploy.

What is a 301 redirect?

A 301 redirect is an HTTP status code a server sends when a page has moved permanently to a new address. When a browser or a search-engine crawler requests the old URL, the server answers with 301 Moved Permanently plus a Location header pointing at the new URL. The browser then automatically requests the new address — usually so fast the visitor never notices anything happened.

That single response does three jobs at once. First, it keeps visitors from hitting dead ends: bookmarks, old emails, and links from other sites keep working. Second, it tells search engines the move is permanent, so Google transfers the old page's ranking signals — backlinks, history, relevance — to the new URL and eventually swaps the old URL for the new one in its index. Third, it is cacheable: browsers are allowed to remember a 301, which makes repeat visits faster but also means a 301 is hard to undo (more on that in the tips below).

When to use a 301 redirect

Use a 301 whenever a URL has moved for good and will not come back. The classic cases:

  • Domain migration. oldshop.example becomes newshop.example — every old page 301s to its counterpart on the new domain.
  • HTTP to HTTPS. Every http:// URL permanently moves to its https:// version.
  • www canonicalization. Pick one host — www.example.com or example.com — and 301 the other to it, so link equity is not split across two versions of the same site.
  • URL restructuring. A redesign changes /blog/2021/05/summer-sale to /blog/summer-sale; the old path 301s to the new one.
  • Trailing-slash and case normalization. Consolidating /About and /about/ onto a single canonical URL.
  • Retired content. A discontinued product page 301s to the closest equivalent page — not to the homepage (see the soft-404 tip below).

The permanence test is simple: will the old URL ever legitimately serve content again? If the answer is no, use 301. If the move is short-term — a maintenance page, a promo, an A/B test — use 302 instead.

301 vs 302 vs 307 vs 308

All four are redirects, but they differ in permanence and in whether the HTTP method is preserved:

CodeNamePermanent?Method preserved?Use it when
301Moved PermanentlyYesUsually rewritten to GETA page moved for good (the default choice)
302FoundNoUsually rewritten to GETTemporary move: maintenance, promos, A/B tests
307Temporary RedirectNoYesTemporary move where a POST must stay a POST (forms, APIs)
308Permanent RedirectYesYesPermanent move where a POST must stay a POST

For ordinary page migrations, 301 is the right answer. The method-preservation difference only matters when the request carries a body: a 301 or 302 may turn a form POST into a GET (dropping the submitted data), while 307 and 308 repeat the original method against the new URL. If you are redirecting API endpoints or form handlers permanently, prefer 308; temporarily, prefer 307.

SEO impact of a 301

A correct 301 passes essentially all ranking signals from the old URL to the new one — Google has confirmed that 301s no longer lose PageRank. The old URL eventually drops out of the index and the new URL takes its place. Two things can still go wrong. Chains (/a → /b → /c) force crawlers through extra hops and dilute signals, and mass redirects to the homepage are treated as soft 404s, which pass no value at all. Both are covered in the tips section, and this page's chain validator finds chains in your list automatically.

Where each output format goes

FormatDeploy it inNotes
Apache (mod_rewrite).htaccess or virtual-host configExact anchored RewriteRule; put rules above catch-alls like WordPress
Apache (mod_alias).htaccessSimpler Redirect 301 lines; do not mix with mod_rewrite rules for the same paths
Nginxserver { } blockExact location = matches are fast hash lookups
IISweb.config URL Rewrite sectionFull XML document; 308 is emitted as 301 (IIS has no native 308 type)
CloudflareBulk Redirects dashboard (CSV import)Needs full source URLs; enter your domain or paste absolute URLs
Netlify_redirects file in the publish directoryfrom to status per line
CSVSpreadsheets, scripts, audit trailssource,target,status with proper quoting

Worked example 1: domain migration (bulk)

A shop moves from oldshop.example to newshop.example. The redirect map is pasted into the Bulk tab — full URLs, bare paths, any separator works:

/services/web-design.html, https://newshop.example/services/web-design
https://oldshop.example/blog/2021/05/summer-sale -> https://newshop.example/blog/summer-sale
/shop/blue-jacket | https://newshop.example/products/blue-jacket

Choosing Apache (mod_rewrite) produces exactly this (verified against the generator engine):

RewriteRule ^services/web-design\.html$ https://newshop.example/services/web-design [R=301,L]
RewriteRule ^blog/2021/05/summer-sale$ https://newshop.example/blog/summer-sale [R=301,L]
RewriteRule ^shop/blue-jacket$ https://newshop.example/products/blue-jacket [R=301,L]

Switching the format dropdown to Nginx produces exact-match location blocks instead — for example:

location = /shop/blue-jacket { return 301 https://newshop.example/products/blue-jacket; }

The Netlify format is even terser — one from to status triple per line:

/services/web-design.html https://newshop.example/services/web-design 301

Deployment, step by step:

  1. Back up the current .htaccess.
  2. Paste the block (including RewriteEngine On) above any catch-all rules such as the # BEGIN WordPress section — rules run top to bottom.
  3. Test with curl: curl -s -o /dev/null -D - https://oldshop.example/shop/blue-jacket and confirm a 301 with a Location: https://newshop.example/products/blue-jacket header.
  4. Check one URL that should not redirect, to make sure nothing was over-matched.
  5. Keep the rules for at least a year — and keep the old domain registered.

Worked example 2: HTTP to HTTPS plus www canonicalization

In the Canonicalizer tab, enter example.com, tick force HTTPS, and choose www → non-www. The Apache output is:

RewriteEngine On
# Force HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# www -> non-www
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]

Every variant — http://example.com/x, http://www.example.com/x, https://www.example.com/x — now lands on https://example.com/x with at most one redirect hop. The Nginx equivalent is generated on the second output tab: a port-80 server block returning 301 https://example.com$request_uri for both hostnames, plus a port-443 block moving www.example.com to the apex.

Worked example 3: one regex rule instead of hundreds

A blog moves dated URLs like /blog/2023/07/hello-world to /articles/hello-world. Instead of one rule per post, the Regex tab takes a pattern and a target with $1-style back-references:

  • Pattern: blog/(\d{4})/(\d{2})/([a-z0-9-]+)
  • Target: https://example.com/articles/$3
  • Test path: /blog/2023/07/hello-world → https://example.com/articles/hello-world

The generated Apache rule is:

RewriteRule ^blog/(\d{4})/(\d{2})/([a-z0-9-]+)$ https://example.com/articles/$3 [R=301,L]

The built-in tester shows the substitution result before you deploy, and rejects invalid regex with the exact engine error message.

Practical tips

  • Never build chains. If /a → /b and /b → /c, replace both with /a → /c directly. Every hop costs a round trip, wastes crawl budget, and weakens signal transfer. The Chain tab flags chains, loops, and duplicate sources in your list.
  • Never create loops. /a → /b → /a makes browsers show "too many redirects". The validator catches these.
  • Do not mass-redirect to the homepage. Google treats hundreds of unrelated URLs pointing at / as soft 404s — the ranking value is lost. Map each old URL to the closest equivalent live page, or let it 404 honestly.
  • Order matters in .htaccess. Specific rules go above broad catch-alls; Apache uses the first matching rule.
  • Do not mix mod_alias and mod_rewrite for the same paths — the two modules run at different phases and the interaction surprises people.
  • 301s are cached. Browsers may remember a 301 for months. Test new rules as 302 first (the status dropdown supports it), confirm with curl, then flip to 301.
  • Test with curl, not just your browser (your browser cache lies): curl -s -o /dev/null -D - -L --max-redirs 0 https://old.example/page | grep -i -E "^(HTTP/|location:)". Expect HTTP/1.1 301 and exactly one Location: header per hop.
  • Full URLs in, paths out. The generator strips scheme and host from sources automatically, escapes regex characters (. becomes \.), and anchors every pattern with ^…$ so /shop/blue-jacket never accidentally matches /shop/blue-jacket-xl.

301 Redirect Generator — all processing happens in your browser; your URL lists are never uploaded.

Frequently asked questions

What is a 301 redirect?
A 301 redirect is an HTTP status code meaning "moved permanently." When a server receives a request for the old URL, it replies with status 301 and a Location header containing the new URL. The browser then automatically loads the new address. It is used whenever a page has moved for good: domain migrations, HTTP-to-HTTPS moves, www canonicalization, and URL restructures. Search engines treat a 301 as an instruction to transfer ranking signals to the new URL and eventually replace the old URL in the index.
When should I use a 301 vs a 302 redirect?
Use a 301 when the old URL will never serve content again — the move is permanent. Use a 302 when the move is genuinely temporary: a maintenance page, a limited-time promo, or an A/B test. The distinction matters for SEO: with a 301, Google transfers ranking signals to the new URL and drops the old one from the index; with a 302, Google keeps the old URL indexed because it expects the content to return. Using a 302 for a permanent move is one of the most common and costly migration mistakes, because the new URL never inherits the old page's authority.
Do 301 redirects pass link equity and PageRank?
Yes. Google has confirmed that 301 redirects pass full PageRank — there is no damping penalty for redirecting. Backlinks pointing at the old URL continue to benefit the new URL once the redirect is in place and crawled. That said, a redirect is still one extra hop: keep redirects to a single hop (no chains), point each old URL at the closest equivalent new page rather than the homepage, and leave the rules in place long enough for search engines to process them — at least a year for domain migrations.
What is the difference between 301, 307, and 308 redirects?
All three can be permanent or temporary, but they differ in HTTP method handling. A 301 permanent redirect may cause the client to change a POST into a GET on the second request, which drops form or API payload data. A 308 is the strict permanent redirect: it guarantees the method and body are preserved. A 307 is the temporary counterpart of 308: it preserves the method but signals a temporary move. For ordinary web pages the difference rarely matters, so 301 remains the default. For API endpoints and form handlers, use 308 for permanent moves and 307 for temporary ones.
What is a redirect chain and why is it bad?
A redirect chain is a sequence like /a → /b → /c, where the destination of one redirect is itself redirected. Chains are bad for three reasons: each hop adds a full request-response round trip, slowing down visitors; they waste search engines' crawl budget; and ranking signals weaken slightly with every hop. Google also stops following after a few hops. The fix is always the same: replace the whole chain with a single direct rule, /a → /c. This page's Chain tab detects chains, loops, and duplicate sources in your redirect list automatically.
What is a redirect loop and how do I fix it?
A redirect loop happens when redirects point in a circle — for example /a redirects to /b and /b redirects back to /a. Browsers detect the cycle and show an error like "too many redirects," making the pages completely unreachable. Loops usually come from overlapping rules: a broad pattern that also matches its own destination, or two one-to-one rules that contradict each other. To fix one, list every rule affecting the URL, find the cycle, and either remove the redundant rule or narrow the broad pattern so it no longer matches the destination. The Chain tab on this page flags loops before you deploy.
How long should I keep 301 redirects in place?
Longer than you think. Google's guidance is to keep redirects for at least a year so its systems fully process the move. In practice, for a domain migration you should keep the old domain registered and the redirects live indefinitely — old backlinks and bookmarks never fully expire, and removing the rules resurrects 404s years later. For single-page moves inside one site, a year is usually enough, but there is rarely a cost to leaving a correct redirect in place, so most SEOs never remove them.
Can I redirect all my old URLs to the homepage?
You can, but you should not. Google treats large numbers of unrelated URLs redirecting to a homepage as "soft 404s" — it recognizes there is no real equivalent content and passes no ranking value. Visitors also land somewhere unexpected, which is a poor experience. The correct approach is a redirect map: every retired URL goes to the closest equivalent live page. Only when no equivalent exists should you let the URL return a genuine 404, which is honest and harmless in small numbers.
Why does my browser still redirect after I removed the rule?
Because 301 redirects are cacheable, and browsers aggressively cache them — sometimes for months. After you remove or change a 301, your own browser may keep applying the old one from cache while everyone else sees the fix. Clear the browser cache, test in a private/incognito window, or use curl, which never caches. This stickiness is also why professionals test new redirects as 302 (temporary) first and only switch to 301 after verifying — this page's status dropdown supports exactly that workflow.
Should I use mod_rewrite or mod_alias for redirects in .htaccess?
Both work; the rule is to pick one and not mix them for the same paths. mod_alias (Redirect 301 /old /new) is simpler and slightly faster, and it is fine for plain one-to-one mappings. mod_rewrite (RewriteRule) is required when the site already uses it — WordPress and most PHP frameworks do — because the two modules execute at different phases and interleaving them produces surprising orderings. As a practical default: if your .htaccess already contains RewriteRule lines, generate mod_rewrite rules; otherwise mod_alias is fine.
How do I test a redirect with curl?
Run: curl -s -o /dev/null -D - -L --max-redirs 0 followed by the old URL, then pipe to grep -i -E "^(HTTP/|location:)". You should see exactly one HTTP status line reading 301 (or your chosen code) and one Location header with the new URL. The --max-redirs 0 flag stops curl from following the redirect, so you inspect a single hop — remove it to watch the whole chain. Do not rely on your browser for testing: its cache can show you a stale redirect long after the server is fixed.
Is there a limit to how many redirects I can generate?
This tool runs entirely in your browser with no server round trip, so there is no artificial limit — pasting thousands of pairs is fine, and output is generated instantly. Practical limits live on the deployment side: very large .htaccess files slow down every request on Apache, so migrations with tens of thousands of rules belong in the server config or a database-driven redirect system instead. Cloudflare's Bulk Redirects feature also caps the number of URL redirects per list depending on your plan, so check your plan limits before importing a huge CSV there.

301 Redirect Generator — free bulk redirect rule generator. No account, no upload.

Free tool by NRTechStudio