Redirect Rules Generator
Paste old and new URLs to get 301, 302, 307 or 308 redirect rules for Apache .htaccess, Nginx, Netlify _redirects and vercel.json, with loop and chain checks.
The interactive tool loads here when JavaScript runs.
About this toolWhat is the Redirect Rules Generator?
Paste a list of old and new URLs, one pair per line, and this generator writes the redirect rules for the server or host you deploy to: Apache .htaccess using mod_rewrite, an Nginx server block, a Netlify _redirects file or the redirects array of vercel.json. Each line can carry its own status code (301, 302, 307 or 308), and a source ending in /* moves a whole folder while keeping the rest of the path, so /blog/* to /news/:splat sends /blog/2024/launch to /news/2024/launch.
Before you copy anything, the rules are checked. The tool flags redirects that point to themselves, prefix rules whose destination falls inside the folder being moved (an endless loop), duplicate sources where only the first rule would ever fire, and chains such as A to B to C, which cost every visitor and crawler an extra round trip. Site-wide options add an HTTP to HTTPS redirect and a canonical host rule that sends www to the bare domain or the other way round.
- Apache .htaccess (mod_rewrite), Nginx, Netlify _redirects and vercel.json output
- 301, 302, 307 and 308 per line, with a default
- Folder (prefix) redirects with the remaining path carried over
- Loop, chain, duplicate and syntax checks
- HTTPS and www or non-www canonical rules
- Copy or download, all in the browser
How to use the Redirect Rules Generator
- Enter one redirect per line: the old path, the new path or full URL, and optionally a status code. Separate columns with spaces, tabs or commas.
- End a source with /* to redirect everything under a folder; use :splat or nothing at the end of the destination.
- Choose the default status code and whether to keep the incoming query string.
- Optionally add HTTP to HTTPS and canonical host rules with your domain.
- Pick Apache, Nginx, Netlify or Vercel, fix anything listed under Checks, then copy or download the file.
Worked examples
One page on Apache
Input
/old-page /new-page
Output
RewriteRule ^old-page/?$ /new-page [R=301,L]
The pattern is anchored at both ends and accepts an optional trailing slash, so /old-page-2 is not caught by mistake.
A folder on Nginx
Input
/blog/* /news/:splat
Output
location ~ ^/blog/(.*)$ { return 301 /news/$1$is_args$args; }The captured path and the query string are both carried over.
An API move on Vercel
Input
/api/v1/upload /api/v2/upload 308
Output
{ "source": "/api/v1/upload", "destination": "/api/v2/upload", "permanent": true }permanent: true is Vercel's 308, which keeps POST bodies intact.
A chain caught
Input
/a /b and /b /c
Output
Warning: Chain /a → /b → /c
Point /a straight at /c so visitors and crawlers take one hop instead of two.
Background and insight
RFC 9110 defines four redirect codes you will use. 301 Moved Permanently and 302 Found are the originals; for historical reasons clients may change a POST into a GET when following them. 307 Temporary Redirect and 308 Permanent Redirect (RFC 7538) require the client to repeat the same method and body. Google treats 301 and 308 as strong signals that the target should replace the old URL in search results, and 302 and 307 as weak ones. Browsers cache permanent redirects, sometimes until the cache is cleared, so a wrong 301 is hard to take back.
Each platform has its own syntax and quirks. Apache's mod_alias Redirect directive matches a prefix and appends the rest of the path, which surprises people who meant one page; this tool uses mod_rewrite with anchored patterns instead, and mod_rewrite appends the original query string unless you add the QSD flag. Nginx's return directive does not add the query string by itself, so the generated rules append $is_args$args when you keep it. Netlify matches rules with or without a trailing slash, passes query strings through for 301 and 302, and skips a rule when a real file exists at the source unless you force it with an exclamation mark. Vercel uses "permanent": true for 308 and false for 307, and statusCode for 301 or 302.
Redirect order matters on every platform: Netlify and Vercel use the first matching rule, Apache processes RewriteRules top to bottom until one with the L flag matches, and Nginx checks exact "location =" blocks before regular expressions. Put specific rules before general folder rules.
Common use cases
Site migrations and redesigns
Turn a spreadsheet of old and new URLs into server rules without losing search rankings.
Moving between hosts
Rewrite existing .htaccess redirects as Netlify or Vercel rules when leaving shared hosting.
Cleaning up URLs
Merge duplicate pages, rename slugs, and enforce HTTPS and a single host name.
API versioning
Send old endpoints to new ones with 307 or 308 so clients keep their method and body.
Tips and limitations
- Test with curl -I https://example.com/old-page and check the status and Location header before announcing a migration.
- Use 302 while testing and switch to 301 or 308 once the rules are right, because browsers cache permanent redirects.
- Redirect each old URL to its closest equivalent page, not everything to the home page; Google treats mass redirects to the home page as soft 404s.
- Update internal links and sitemaps to the new URLs too; redirects are for visitors and crawlers arriving from outside.
- Keep redirects in place for at least a year after a move; Google recommends keeping them as long as possible.
Frequently asked questions
How do I redirect one page to another in .htaccess?
With mod_rewrite enabled, add RewriteEngine On and then RewriteRule ^old-page/?$ /new-page [R=301,L]. In .htaccess the pattern is matched without the leading slash. The L flag stops processing at that rule.
What is the difference between 301 and 302 for SEO?
A 301 says the move is permanent, so search engines transfer the old page's signals and show the new URL. A 302 says it is temporary, so they usually keep the old URL indexed. Use 301 or 308 for migrations.
Does an Nginx return 301 keep the query string?
No. return sends exactly the URL you give it. Append $is_args$args to keep the query string, as this generator does when "Keep query string" is on. A rewrite directive, by contrast, appends the arguments automatically.
Why does my Netlify redirect not work?
Usually because a file exists at the source path, so Netlify serves it instead (shadowing). Add ! after the status, as in 301!, to force the rule. Also check that a more general rule higher in the file is not matching first.
How do I force HTTPS and remove www?
On Apache, add a RewriteCond on %{HTTP_HOST} for the www name and a RewriteCond on %{HTTPS} off, each followed by a RewriteRule to https://example.com/$1 with R=301. On Nginx use separate server blocks that return 301 to the canonical host. Netlify and Vercel enforce HTTPS automatically.
What is a redirect chain and why does it matter?
A chain is one redirect leading to another, such as A to B to C. Every hop adds a round trip for visitors, and crawlers may stop following after several hops. Point every old URL directly at its final destination.
Is there an in-depth guide to the Redirect Rules Generator?
Yes. “301, 302, 307 or 308? Writing Redirects for Apache, Nginx, Netlify and Vercel” covers the background, how it works, common pitfalls and worked examples. Read the full guide.
People also search for
- htaccess 301 redirect old page to new page
- nginx redirect one url to another
- netlify redirects file example splat
- vercel json redirect permanent 301
- redirect whole folder to new folder htaccess
- force https and non www htaccess
- how to find redirect chains before migration
- nginx return 301 keep query string
Related Tools You May Like
Free, in-browser tools that pair well with this one.