Zahid Awais Get a free audit

Free Nginx redirect generator

Generate clean Nginx return and rewrite rules for any redirect, from one page to a full domain move.

By Zahid Awais · Technical SEO tools · Free, private, no sign-up

Result
0Rules
301Status
0Warnings
    Nginx Redirect Generator: what it does and an example result

    The free nginx redirect generator runs in your browser, needs no sign-up and never sends what you type anywhere.

    Quick answer

    This Nginx redirect generator writes return and rewrite rules for single pages, folders, bulk lists, domain moves, HTTPS and www. Rule of thumb: prefer return 301 over rewrite for simple redirects because it is faster and clearer, use exact location = matches for single URLs, and run nginx -t before reloading.

    What is a nginx redirect generator?

    An Nginx redirect generator is a tool that turns old and new URLs into Nginx configuration such as location = /old/ { return 301 URL; }, rewrite rules with the permanent flag, or a map block for bulk lists. It escapes paths, keeps the query string where needed with $request_uri and outputs the status code you choose.

    How do you use the Nginx Redirect Generator?

    How to use the Nginx Redirect Generator: enter details, see the result and copy it
    Real screenshot of the Nginx Redirect Generator with the steps marked.
    1. Choose the redirect type: single page, folder, bulk list, whole domain, force HTTPS, or force www or non-www.
    2. Enter the old path and the new URL, or paste a list of pairs for bulk mode.
    3. Pick 301 for permanent moves or 302 for temporary ones.
    4. Paste the rules into the right server block (or http block for the map) in your site config.
    5. Run sudo nginx -t to test the syntax, then sudo systemctl reload nginx and check the old URL.

    Should I use return or rewrite for Nginx redirects?

    Use return for most redirects because it stops processing immediately and is easier to read. Use rewrite only when you need a regex capture, such as moving a folder while keeping the rest of the path. Both are covered in the Nginx rewrite module documentation.

    Where do Nginx redirect rules go?

    Single page and folder rules go inside the server block for the site, usually in /etc/nginx/sites-available/ or /etc/nginx/conf.d/. A map block for bulk redirects must sit in the http context, outside any server block. Domain and HTTPS redirects usually get their own server block.

    How do I keep the query string in an Nginx redirect?

    Use $request_uri, which contains the path and the query string, as in return 301 https://example.com$request_uri;. With rewrite, the original arguments are appended automatically unless you end the replacement with a question mark. This tool picks the right form for each mode.

    Quick reference

    GoalNginx ruleStatus
    One exact pagelocation = /old/ { return 301 https://example.com/new/; }301
    Whole folderrewrite ^/blog/(.*)$ /articles/$1 permanent;301
    Temporary pagelocation = /sale/ { return 302 https://example.com/offers/; }302
    HTTP to HTTPSreturn 301 https://$host$request_uri;301
    Old domainserver_name old.com www.old.com; return 301 https://new.com$request_uri;301

    Worked example

    Example

    Example: you move every post from /blog/ to /articles/. Folder mode with old /blog/ and new /articles/ outputs rewrite ^/blog/(.*)$ /articles/$1 permanent;. A request for /blog/seo-tips/?ref=x returns one 301 to /articles/seo-tips/?ref=x because rewrite keeps the query string.

    Frequently asked questions

    Why is my Nginx redirect not working?

    Common causes are editing the wrong server block, a more specific location catching the request first, or forgetting to reload Nginx. Run nginx -t to test syntax, reload, then test in a private window, because browsers cache 301 redirects aggressively.

    What is the difference between permanent and redirect flags?

    In a rewrite rule, the permanent flag sends a 301 and the redirect flag sends a 302. If the replacement starts with http://, https:// or $scheme, Nginx redirects even without a flag. The last and break flags rewrite internally and send no redirect.

    How many redirects can Nginx handle?

    Thousands. For large lists use a map block, because Nginx looks up map entries in a hash table, which stays fast as the list grows. Hundreds of separate location blocks work too but are harder to maintain.

    Can I use if for redirects in Nginx?

    Only for simple checks such as testing a map variable and returning. Complex logic inside if blocks is discouraged in Nginx because it can behave unexpectedly. The patterns in this tool use if only with return, which is the safe case.

    Does this tool work for Apache?

    No, the output is Nginx syntax only. Apache and LiteSpeed sites that use .htaccess files need our htaccess redirect generator instead. Planning a whole migration? Build a redirect map first so every old URL has a match.

    Is anything I enter sent to a server?

    No. The rules are generated in your browser with JavaScript and nothing is uploaded or stored. Always test the generated config on a staging server or with nginx -t before reloading production.

    Sources

    Facts checked against these official pages. Read how I check facts in my editorial policy.

    Related free tools

    All 104 tools

    Canonical Tag Generator

    A canonical tag generator is a tool that builds the link rel="canonical" element telling search engines which…

    Redirect Map Generator

    A redirect map generator is a tool that builds the old URL to new URL table you need before a site migration.…

    Want a full audit instead?

    Send your website and I will check it for you, free.

    Get my free audit
    Chat on WhatsApp
    Free updates

    Get new tools, guides and coupons first

    One short email when something new goes live: articles, free SEO tools, package updates, discounts and price alerts. No spam, unsubscribe in one click.