Skip to content
Rankora
Free · runs in your browser

Nginx Redirect Generator

For a long list the tool writes a map table (hash lookup, no regex); for a few pages, location blocks. It also writes the server blocks for HTTPS, www and domain moves.

Privacy and cost

This tool runs in your browser. What you type or paste is not sent to our servers and it costs nothing to use.

How it works

  1. Pick the mode: pages and folders, HTTPS / www / trailing slash, or a domain move.
  2. Paste the list or enter the domains, then choose map or one location per rule.
  3. Put the map block in the http context and the rest in the labelled server block, test with nginx -t and reload.

Example

For "/old-page /new-page" the map mode writes the keys "/old-page" and "/old-page/" pointing to "/new-page", followed by an if that runs return 301 and keeps the query string. For example.com with HTTPS and www, one block listens on port 80 for "example.com www.example.com" and returns return 301 https://www.example.com$request_uri.

What the result means

Nginx does not read .htaccess: redirects live in the server configuration. A map compares the exact path and stays fast with thousands of lines. Folder and query-string rules use if followed by return, the safe use of if. Values are quoted and the $ sign in targets is encoded so it cannot become a variable.

Common problems this tool helps with

  • A map must be declared in the http context, not inside server, or nginx -t fails.
  • Two identical keys in a map stop nginx at startup; the tool removes duplicates.
  • A trailing slash removed on a real directory loops with nginx's automatic slash unless the -d guard is there.
  • Rules with a host name belong in that host's server block, not in a global map.

Frequently asked questions

return 301 or rewrite?

return is simpler and faster for a redirect: nginx answers straight away. rewrite ... permanent is for reusing part of the path with a regex, but it only knows 301 and 302.

Do I need many rules to use a map?

No, but it pays off from a few dozen lines. Beyond a hundred entries the tool adds map_hash_max_size and map_hash_bucket_size.

Where do the certificates come from?

The 443 blocks contain sample ssl_certificate paths. Replace them with your own files (Let's Encrypt, your host…).

Is my data sent anywhere?

No, generation runs in your browser.