Turn a list of old and new URLs into Nginx return 301 rules and server blocks
Runs in your browser. Nothing you type is sent anywhere. Checked against sources on 16 Oct 2026.Nginx redirects are written with return, not rewrite: one exact location = /old-page block per page, and a small server block to send HTTP to HTTPS and www to the bare domain, or the other way round. Paste your old and new addresses and enter the domain, and the blocks are written for you, with the query string carried over by $is_args$args unless you turn that off.
Paste one redirect per line: the old path, a space, then the new path or URL.
Check that Nginx is selected and type your domain, such as example.com.
Copy the location blocks into your server block, and the canonical server blocks above it.
Run nginx -t to check the configuration, then reload Nginx.
Paste one redirect per line, the old address and then the new one, and the rules are written as you type. Old addresses can be paths or full URLs copied from a browser or an analytics export; tabs, commas and arrows also work, so a spreadsheet column pair pastes straight in. Add a code at the end of a line to override the default, or write 410 instead of a new address for a page that is gone.
Apache. Every rule uses mod_rewrite. The simpler Redirect directive matches prefixes, so Redirect /shop /store also catches /shopping, and mixing the two modules runs them in an order that surprises people. Patterns are anchored and escaped, so a dot in old.html matches only a dot. An old address with a query string, such as /products?id=42, gets its own RewriteCond and the query is dropped from the new address.
Nginx. Each page gets an exact location = block with return. HTTPS and the www choice get their own server blocks, which need your domain.
The rest of the article, and all 6 questions about .htaccess Redirect Generator, are on the .htaccess Redirect Generator page.
Add RewriteEngine On once, then one line per page: RewriteRule ^old-page$ /new-page [L,R=301]. The pattern has no leading slash in .htaccess, the caret and dollar make it match only that exact page, and R=301 makes the move permanent. Place the rules near the top of the file, before any WordPress or framework block.
Combine the conditions so the visitor makes a single hop: redirect when HTTPS is off or the host starts with www, and send them to https plus the host without www. This generator writes exactly that with three RewriteCond lines and one RewriteRule, or a pair of server blocks for Nginx, instead of two separate redirects in a row.
A loop happens when a rule sends a page to an address that the same or another rule redirects back. Common causes are redirecting /page to /page/ while another rule strips the slash, or forcing HTTPS behind Cloudflare Flexible SSL, where the server always sees HTTP. This tool refuses rules that loop and names the line.
RewriteRule never sees the query string, so match it with a RewriteCond first: RewriteCond %{QUERY_STRING} ^id=42$, then the RewriteRule for the path. Add the QSD flag so ?id=42 is not copied onto the new address. Pasting /products?id=42 /products/blue-mug here writes both lines for Apache, or an if ($args) test for Nginx.
Rates and rules change; check the source before you rely on a figure.
Still stuck? Ask about .htaccess Redirect Generator and anybody who knows can answer. No account needed.
On the related tools: Cron Expression Generator – Generate a cron expression by choosing when the job should run · Sitemap Index Generator – Split a large site into numbered sitemaps with an index file · Google Analytics URL Builder – The five utm parameters GA4 reads, with the naming traps flagged.