Skip to content

301 Redirect Generator — .htaccess, Nginx, Vercel & Netlify Rules

Turn a list of old and new URLs into redirect rules for Apache .htaccess, Nginx, vercel.json or Netlify, and catch chains, loops and duplicates.

Separate the columns with a tab (paste two columns from a spreadsheet), a comma or a space; use a tab or comma when a path contains spaces. Old URLs can be paths or full URLs on your site. Lines starting with # are ignored.

Server / platform
8 redirects ready
Checks
  • Conflict: lines 2, 9 send the same URL to different places. Only the first one will ever run.
  • Chain: lines 3 → 4 redirect one after another. Point the first URL straight to /guides/seo to save hops.
Rules

Paste into the .htaccess file in your site's root (or a <VirtualHost> block). RewriteRule needs mod_rewrite; QSD needs Apache 2.4.

RewriteEngine On

# line 5
RewriteCond %{QUERY_STRING} ^id=42$
RewriteRule ^products\.php/?$ /products/blue-widget [R=301,L,QSD]

# line 2
RewriteRule ^about-us/?$ /about [R=301,L]

# line 3
RewriteRule ^blog/2019/seo-tips/?$ /blog/seo-tips [R=301,L]

# line 4
RewriteRule ^blog/seo-tips/?$ /guides/seo [R=301,L]

# line 6
RewriteRule ^old\x20page\.html/?$ /new-page [R=301,L]

# line 7
RewriteRule ^summer-sale/?$ /sale [R=302,L]

# line 8
RewriteRule ^contact\.html/?$ https://example.com/contact [R=301,L]

# line 9
RewriteRule ^about-us/?$ /company [R=301,L]

Runs entirely in your browser. Your URL list is never uploaded. Browse all free tools.

Found a problem, or something that could be better? We read every message and we fix things quickly.

This 301 redirect generator turns a list of old and new URLs into redirect rules for an Apache .htaccess file, an Nginx server block, vercel.json or a Netlify _redirects file. Paste two columns from a spreadsheet, choose 301, 302, 307 or 308, and copy the rules for your server. It is built for site migrations and URL clean-ups where you have dozens or thousands of redirects to write.

Before writing anything, it checks the list for the mistakes that cost rankings and visitors: the same URL listed twice with different targets, chains such as A → B → C that add a hop for every visitor and crawler, loops that make pages unreachable, and URLs that redirect to themselves. Chains can be collapsed in one click. The generated rules handle what each server needs: escaped regex patterns, spaces and accented characters in paths, back-reference characters in targets, and whether the visitor's query string is kept. The Apache output was tested on a real Apache 2.4 server; test any rules on a staging site before deploying.

How to use

  1. Paste your redirects, one per line: old URL, new URL and optionally a status code, separated by a tab, comma or space.
  2. Pick the platform: Apache (.htaccess), Nginx, Vercel or Netlify.
  3. Choose the default status (301 for permanent moves) and the options: trailing slash, query string, chain collapsing.
  4. Fix anything listed under Checks: conflicts, chains, loops or self-redirects.
  5. Copy the rules or download the file, add them to your server configuration and test a few old URLs.

Frequently asked questions

How do I write a 301 redirect in .htaccess?

For a single page, use mod_rewrite: "RewriteEngine On" once, then "RewriteRule ^old-page/?$ /new-page [R=301,L]". In .htaccess the pattern is matched without the leading slash, dots and other regex characters must be escaped, and [L] stops processing at the first match. The simpler "Redirect 301 /old-page /new-page" also works but matches by prefix, so it also redirects /old-page/anything. This generator writes either form from your list.

What is the difference between 301, 302, 307 and 308 redirects?

301 and 308 are permanent: search engines move ranking signals to the new URL and browsers cache the redirect. 302 and 307 are temporary: the old URL stays indexed. 307 and 308 also guarantee the request method is kept (a POST stays a POST), while browsers may change POST to GET on 301 and 302. For moved pages, 301 is the usual choice; 308 is equivalent for search engines.

What is a redirect chain and why does it matter?

A chain is a redirect that leads to another redirect: /a → /b → /c. Every hop is an extra request, which slows visitors down, and Google follows at most 10 hops before giving up. Chains build up over several migrations. The generator lists each chain with the lines involved and its final URL; tick "Collapse chains" and every old URL points straight to the end.

How do I redirect a URL with a query string?

Write the old URL with its query, such as /product.php?id=42. In Apache the generator adds a RewriteCond on %{QUERY_STRING} and drops the old query with QSD; in Nginx it adds an if ($args = ...) check inside the location; in vercel.json it adds a has condition for each parameter. Netlify's _redirects can match query parameters only by name, not by value, so those lines are written as comments for you to handle another way.

Where do I put the generated redirect rules?

Apache: in the .htaccess file in your site's root (or in the VirtualHost configuration, which is faster). Nginx: inside the server { } block, then run nginx -t and reload. Vercel: in the redirects array of vercel.json at the project root. Netlify: in a file named _redirects in the publish directory. On every platform, the first matching rule wins.

Redirect rules on each platform

• Apache RewriteRule: regex on the decoded path, without the leading slash in .htaccess. $1 and %1 in the target are back-references, so literal ones are escaped. [NE] stops a target with %20 or # from being encoded again. QSD (Apache 2.4+) drops the old query string, QSA merges it.

• Apache Redirect (mod_alias): a prefix match on whole path segments that always passes the query string on and cannot match on it. Longer paths are written first, because the first match wins, and the home page uses an anchored RedirectMatch so it does not catch the whole site.

• Nginx: location = /path for an exact match (or a regex location for an optional trailing slash) and return with the status. return drops the query string unless $is_args$args is appended. A literal $ in a URL is written %24, because Nginx has no escape for it.

• Vercel: permanent: true gives 308 and false gives 307; 301 and 302 need statusCode. Sources are path-to-regexp patterns, so ( ) : * + ? { } are escaped. Redirects count toward the 2,048 routes per deployment.

• Netlify: whitespace-separated lines, 301 by default. Netlify documents 301 and 302 for redirects, so 307 and 308 are mapped to them, and query strings are passed on automatically. A rule does not run if a file exists at the old path, unless it is forced with !.

A redirect checklist for site migrations

• Map every old URL that has traffic or backlinks to its closest new equivalent, not to the home page. Google treats mass redirects to the home page as soft 404s.

• Use 301 (or 308) for permanent moves; keep 302 and 307 for things that will come back.

• Collapse chains from earlier migrations so each old URL takes one hop.

• Update internal links, canonical tags and the XML sitemap to the new URLs; redirects are a safety net, not a substitute.

• Keep the redirects in place for at least a year, and test a sample of old URLs after deploying.