Nginx Redirect Generator
Turn an old-to-new URL list into nginx 301 redirect config — return or rewrite directives, plus HTTPS and www canonical server blocks. Copy or download.
nginx configuration — 2 redirects
Test with nginx -t before reloading. Query strings are carried over automatically by both return and rewrite.
What is the Nginx Redirect Generator?
The Nginx Redirect Generator converts a plain old-URL → new-URL list into ready-to-paste nginx configuration.
- Bulk paste: comma, tab, space or arrow separated old → new pairs
- Exact location = { return } blocks or regex rewrite directives
- 301 / 302 switch (permanent / redirect for rewrite syntax)
- HTTP→HTTPS and www / non-www canonical server blocks
- Flags duplicate sources and malformed lines before they hit production
- Copy-ready output plus .conf download, fully client-side
How to use the Nginx Redirect Generator
- 1
Paste your redirects, one per line: /old-path /new-path (comma, tab or → also work).
- 2
Choose exact-match return blocks or regex rewrite directives.
- 3
Pick 301 permanent or 302 temporary.
- 4
Optionally enable the HTTPS and www canonicalization server blocks with your domain.
- 5
Copy the config or download redirects.conf and include it in your server block.
About the Nginx Redirect Generator
The Nginx Redirect Generator converts a plain old-URL → new-URL list into ready-to-paste nginx configuration. Paste one mapping per line (separated by a comma, tab, space or arrow) and choose between exact-match location blocks with return — the fastest, safest form — or rewrite directives when you need regex captures.
It also generates the canonical server blocks every site needs once: HTTP→HTTPS redirection and www / non-www consolidation, written as separate server blocks the way nginx best practice dictates, with placeholders for your certificate paths. Redirect type is switchable between 301 (permanent) and 302 (temporary).
This is the nginx counterpart to our .htaccess Redirect Generator for Apache. Everything is generated 100% locally in your browser — your URL list is never uploaded — and the output downloads as a .conf file you can include from your server config.
Frequently asked questions
Should I use return or rewrite for nginx redirects?
Use return inside an exact-match location block whenever the mapping is one fixed URL to another — it is faster and impossible to get regex-wrong. Reserve rewrite for pattern work, like moving a whole directory with a capture group such as rewrite ^/blog/(.*)$ /articles/$1 permanent;.
What is the difference between a 301 and 302 redirect for SEO?
A 301 is permanent: search engines transfer the old URL's signals to the new one and eventually replace it in the index. A 302 is temporary and keeps the old URL indexed. For site migrations and URL cleanups you almost always want 301.
Where do I put these redirect rules in my nginx config?
The location and rewrite directives go inside the server block that serves your site, typically via an include file such as include /etc/nginx/snippets/redirects.conf;. The HTTPS and www canonical blocks are separate server blocks at the same level as your main one. Test with nginx -t before reloading.
How do I redirect HTTP to HTTPS in nginx?
With a dedicated server block listening on port 80 that returns 301 https://yourdomain$request_uri for all traffic — exactly what this generator emits. Avoid if-based rewrites for this; the standalone block is the pattern nginx's own documentation recommends.
Do query strings survive these redirects?
With return 301 /new-page;, nginx appends the original query string automatically. In rewrite rules the query string is also carried over unless you end the target with a ?. So /old?utm_source=x lands on /new?utm_source=x with the default output of this tool.
Related tools
Htaccess Redirect Generator
Generate Apache .htaccess 301 and 302 redirect rules from old-to-new path rows, plus one-click force HTTPS and force www or non-www canonicalization.
Robots.txt Tester
Paste your robots.txt, a URL path and a user-agent to see if crawling is allowed or blocked, with the exact deciding rule highlighted. Free and private.
Canonical Tag Generator
Generate a correct rel=canonical link tag from any URL, with optional trailing-slash and lowercase normalization. Fix duplicate content the easy way.
URL Encoder
Percent-encode text for URLs instantly. Switch between encodeURIComponent and encodeURI modes, see live output and copy the result. Free URL encoder.