Nginx Redirect Generator
Paste a list of old paths and new paths and get an nginx server block with matching return directives, or redirect an entire domain in one go.
Redirect type
One redirect per line. Separate the old and new path with a space, comma, or tab. Use * in wildcard mode to carry the rest of the path across.
Matching
Redirect code
Everything runs in your browser. Nothing is uploaded.
nginx server block
2 rules generated
How to generate an nginx redirect
Choose path list or whole domain
Pick path list to redirect specific old paths to new ones, or whole domain to send every request to a different domain.
Enter your redirects
Paste one old path and new path per line, separated by a space, comma, or tab, or type the new domain for a whole-domain redirect.
Set matching and redirect type
Choose exact, prefix, or wildcard matching, pick 301 or 302, and decide whether to preserve the query string.
Copy or download the server block
Copy the generated nginx server block into your site configuration, or download it as a file.
Why use this tool
Path list or whole-domain mode
Redirect a specific list of old paths to new ones, or switch to whole-domain mode to send every request to a new domain while keeping the original path.
Exact, prefix, and wildcard matching
Match a path exactly, match anything starting with a prefix, or use a single wildcard in the old path to carry the rest through to the new one.
301 or 302 redirects
Switch between a permanent 301 redirect and a temporary 302 redirect for every rule at once.
Query string control
Choose whether the original query string is carried through to the destination or dropped.
Runs entirely in your browser
The server block is generated on your device; nothing about your paths or domain is uploaded.
About this tool
Redirecting old URLs to new ones in nginx means writing a location block with a return directive for each path, which is easy to get wrong when a project has more than a handful of redirects. This tool builds that configuration from a plain list of old-path to new-path pairs, one per line, separated by a space, comma, or tab.
Choose exact matching for a path that should redirect on its own, prefix matching for anything that starts with a given path, or wildcard matching to carry a trailing part of the old path through to the new one using a single asterisk, such as redirecting /blog/* to /articles/*. Every rule is wrapped in a single server block using the return directive, with a 301 or 302 status code and an option to preserve or drop the original query string.
A separate whole-domain mode covers the common case of moving a site to a new domain: enter the new domain and every request to the old one is redirected there while keeping the original path. When it looks right, copy the server block into your nginx configuration or download it as a file. Everything runs locally in your browser, so no path or domain is ever uploaded. For an equivalent configuration in Apache, use the .htaccess redirect generator.
Frequently asked questions
- What is the difference between exact and prefix matching?
- Exact matching only redirects a request that matches the old path precisely. Prefix matching redirects any request whose path starts with the old path, so /old/anything would also redirect if the old path is /old.
- How does wildcard matching work?
- Put a single asterisk in the old path to capture everything at that position, such as /blog/*. The matching part of the request is carried through to the new path wherever an asterisk appears there too, such as /articles/*, which becomes a regex location behind the scenes.
- What is the difference between a 301 and a 302 redirect?
- A 301 is a permanent redirect and tells search engines to transfer ranking signals to the new URL. A 302 is temporary and keeps the original URL as the one that stays indexed, which suits a short-lived change.
- Does the redirect keep the query string?
- With preserve query string on, anything after a question mark in the original request is carried through to the destination. Turn it off to always land on the destination without any original query parameters.
- How do I redirect an entire domain?
- Switch to whole domain mode, type the new domain, and choose http or https. Every request to the current server is sent to that domain on the same path, so /about becomes newdomain.com/about automatically.
- Is anything I type uploaded anywhere?
- No. The server block is generated entirely in your browser and nothing is sent to a server.
Related tools
.htaccess Redirect Generator
Turn a list of old and new URLs into Apache redirect rules. Set each row to exact or pattern matching, force HTTPS, canonicalize www, then copy a ready .htaccess block wrapped in <IfModule mod_rewrite.c>.
ROT13 Encoder
Apply the classic ROT13 cipher or any ROT-N shift from 1 to 25. Letters rotate, everything else stays put, and you get the encoded and decoded text at once.
Semantic Version Calculator
Compare two versions by semantic-versioning precedence, work out the next release with a bump, and check a version against a range.
SHA-1 Hash Generator
Hash any text or file to its SHA-1 digest as you type, then copy it as lowercase hex, uppercase hex, or Base64.
SHA-512 Hash Generator
Hash any text or file with SHA-512 as you go, switch to SHA-384, and copy the digest as lowercase hex, uppercase hex, or Base64.
XML Sitemap Generator
Turn a list of page URLs into a valid sitemap.xml. Add lastmod, changefreq, and priority, then copy or download the file.