SEO ToolsA little help for every day

Search by name or task, such as JSON or percentage.

SEO Tools

301 Redirect Rule Generator

Turn a list of old and new URLs into 301, 302, 307 or 308 redirects for Nginx, Apache .htaccess, Cloudflare Bulk Redirects CSV and _redirects files.

View all tools
ResultUpdates as you type
# Nginx: put inside the site's server { } block, then run nginx -s reload
location = /old-page {
    return 301 /new-page$is_args$args;
}
location = /products/old-item {
    return 301 /products/new-item$is_args$args;
}
location = /promo {
    return 302 https://shop.example.com/sale$is_args$args;
}
# Apache: add to .htaccess in the web root or a <VirtualHost>; needs mod_rewrite
RewriteEngine On
RewriteRule ^/?old-page$ /new-page [R=301,L]
RewriteRule ^/?products/old-item$ /products/new-item [R=301,L]
RewriteRule ^/?promo$ https://shop.example.com/sale [R=302,L]
# Cloudflare Bulk Redirects CSV (delete this line before importing). Columns: source URL, target URL, status, preserve query string, include subdomains, subpath matching, preserve path suffix
example.com/old-page,https://example.com/new-page,301,TRUE,FALSE,FALSE,FALSE
example.com/products/old-item,https://example.com/products/new-item,301,TRUE,FALSE,FALSE,FALSE
example.com/promo,https://shop.example.com/sale,302,TRUE,FALSE,FALSE,FALSE
# Cloudflare Pages / Netlify: save as a file named _redirects in the published folder
/old-page /new-page 301
/products/old-item /products/new-item 301
/promo https://shop.example.com/sale 302

3 rule(s), status 301 / 302. Rules match exactly: /old does not match /old/ or /old/abc.

How to use 301 Redirect Rule Generator

Enter one redirect per line: the old path, the new path or URL and an optional status code. Choose a default status, the output format and whether to keep the query string. The rules update as you type.

  1. List old and new addressesWrite /old-page /new-page on each line, or paste two spreadsheet columns; add 302, 307 or 308 to override.
  2. Choose status and formatPick the default status code, one output or all formats, and your domain for the Cloudflare rows.
  3. Add the rules to your sitePaste them into the Nginx server block, .htaccess, a Cloudflare list or _redirects, then test a few old URLs.

301, 302, 307 or 308?

Use 301 for a permanent move, such as a renamed page or a site migration; search engines take it as a strong signal to index the new URL instead. 302 is a temporary redirect for short-lived changes like a promotion. 307 and 308 are the temporary and permanent equivalents that keep the request method, so a form POST stays a POST, which matters for APIs and form handlers. Each line can override the default status by adding the code at the end, for example /promo https://shop.example.com/sale 302.

Exact matching, query strings and loops

Every rule matches one exact path: /old does not match /old/ or /old/abc, so list both forms if your site serves them. An old address can be a full URL to limit the rule to one host; Nginx output then notes which server block to use and Apache adds a RewriteCond on the host. Old addresses with a ?query are skipped because these rules match paths only. With the query-string option on, parameters such as ?utm_source=… carry over to the target; with it off, Apache rules get the QSD flag to drop them. Lines that would redirect to themselves, and duplicate old paths, are skipped.

Accuracy and data handling

Generated tags and rules must match the real page content and the site's deployment environment. The calculation runs in your current browser; the tool code does not send the input to a processing API.

Often Used Together

Next step

FAQ

How do I create a 301 redirect in .htaccess?

Choose Apache output and enter the old and new paths. Each line becomes a rule such as RewriteRule ^/?old-page$ /new-page [R=301,L] after RewriteEngine On; mod_rewrite must be enabled.

How do I add redirects in Nginx?

Choose Nginx output. Each redirect becomes an exact-match location block containing a return 301 line, which goes inside your site's server block. Reload Nginx afterwards with nginx -s reload.

Can I import the redirects into Cloudflare?

Yes. Choose Cloudflare Bulk Redirects CSV, set your domain and import the file into a Bulk Redirect list. The columns cover source, target, status and the query string, subdomain, subpath and path suffix options.

Does it work for Netlify?

Yes. The Cloudflare Pages / Netlify output writes the old path, target and status on each line; save it as a file named _redirects in your published folder.

More SEO Tools

Related tools