Redirect Rules Generator
Generate ready-to-paste redirect rules for nginx, Apache (.htaccess) and Next.js from a plain list of old-URL to new-URL mappings. Pick a 301/302/307/308 status and get all three server configs at once.
Input
One mapping per line: old path => new path (=> or -> both work). Lines starting with # are ignored.
Output
Guides
The Redirect Rules Generator turns a plain list of old-URL → new-URL mappings into ready-to-paste redirect configuration — for nginx, Apache (.htaccess), and Next.js (next.config.js) all at once. Useful when moving pages during a site migration, restructuring URL slugs, or consolidating duplicate content, without hand-writing three different config syntaxes for the same list.
How to use this tool
- Enter one mapping per line in the format
/old-path => /new-path(->also works). - Pick the redirect status code — 301 (permanent) is the standard choice for URL migrations; 302/307 are for temporary redirects, and 307/308 preserve the original HTTP method.
- Copy or download whichever config matches your stack. Lines starting with
#are treated as comments and skipped.
Where each snippet goes
- nginx — paste the
locationblocks inside yourserver { }block, then reload nginx (nginx -s reload). - Apache — paste the
Redirectlines into your site's.htaccessfile or virtual host config (requiresmod_alias, enabled by default). - Next.js — paste the array into the
redirects()async function innext.config.js, then rebuild.
Frequently asked questions
Why does the Next.js output use statusCode instead of permanent? Next.js's redirects() normally infers a code from a boolean permanent flag (true → 308, false → 307), which can't express 301 or 302. Setting statusCode explicitly guarantees the code you picked is the code that's sent, regardless of which one it is.
Can I use a wildcard or regex path? No — each mapping is an exact path match. For pattern-based rewrites (e.g. an entire old directory tree), use your server's rewrite rules directly; this tool is for one-to-one URL moves.
Is my input sent anywhere? No. Every config is generated entirely in your browser — nothing you type leaves your device. If you also need to verify a redirect is actually live, use the Redirect Checker, which traces a real URL's HTTP redirect chain.
Use it from code
From 3 credits per callREST API
curl -X POST https://api.iotools.cloud/v1/tool/redirect-rules-generator \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"mappings": "/old-page => /new-page\n/blog/2020/post-title => …",
"redirectType": "301"
}'Swap in your own key from your account. The tool's fields are the body — no wrapper.
Ask an AI agent
Use the IOTools `redirect-rules-generator` tool (Redirect Rules Generator) on this input:
YOUR_INPUT_HEREPaste this at any agent connected to the IOTools MCP server, then add your input.