Redirect rules generator
Turn a list of old and new addresses into redirect rules for Apache .htaccess, Nginx, or a Netlify _redirects file.
Input
Result
Fill in the input and press Run.
Your input is processed in memory and then discarded. It is not stored or logged. Even so, don't paste live passwords or keys into any online tool.
Use it from code or an agent
curl -s https://setget.net/v1/tools/htaccess-redirects \
-H 'Content-Type: application/json' \
-d '{"input":{"redirects":[{"from":"/old-page","to":"/new-page"},["/blog/2019/post.html","https://blog.example.com/post"]]}}'
import json, urllib.request
body = {'input': {'redirects': [{'from': '/old-page', 'to': '/new-page'}, ['/blog/2019/post.html', 'https://blog.example.com/post']]}}
request = urllib.request.Request("https://setget.net/v1/tools/htaccess-redirects", json.dumps(body).encode(),
{"Content-Type": "application/json"})
print(json.load(urllib.request.urlopen(request))["result"])
const response = await fetch("https://setget.net/v1/tools/htaccess-redirects", {
method: "POST",
headers: {"Content-Type": "application/json"},
body: JSON.stringify({"input":{"redirects":[{"from":"/old-page","to":"/new-page"},["/blog/2019/post.html","https://blog.example.com/post"]]}}),
});
console.log((await response.json()).result);
Tool: run_tool
Arguments:
{
"slug": "htaccess-redirects",
"input": {
"redirects": [
{
"from": "/old-page",
"to": "/new-page"
},
[
"/blog/2019/post.html",
"https://blog.example.com/post"
]
]
}
}
{
"input": {
"redirects": [
{
"from": "/old-page",
"to": "/new-page"
},
[
"/blog/2019/post.html",
"https://blog.example.com/post"
]
]
}
}
Endpoint: POST /v1/tools/htaccess-redirects. Over MCP: run_tool with slug: "htaccess-redirects".
Machine-readable: input schema, Markdown. Connect an agent.
Inputs
| Name | Type | Required | What it does |
|---|---|---|---|
redirects |
json | yes | The redirects: a list of {"from": "/old", "to": "/new"} objects or ["/old", "/new"] pairs. Plain text with "old new" on each line also works. |
format |
string | no | Which server the rules are for. netlify is the _redirects format, also used by Cloudflare Pages. One of: apache, nginx, netlify. Default: "apache". |
status |
integer | no | 301 for a permanent move (best for SEO), 302 for a temporary one. One of: 301, 302. Default: 301. |
Examples
Input
{
"redirects": [
{
"from": "/old-page",
"to": "/new-page"
},
[
"/blog/2019/post.html",
"https://blog.example.com/post"
]
]
}Result
{
"text": "RedirectMatch 301 ^/old-page$ /new-page\nRedirectMatch 301 ^/blog/2019/post\\.html$ https://blog.example.com/post\n",
"count": 2,
"filename": ".htaccess"
}Nginx, from plain text
Input
{
"redirects": "/old-page /new-page\n/sale /offers",
"format": "nginx",
"status": 302
}Result
{
"text": "location = /old-page { return 302 /new-page; }\nlocation = /sale { return 302 /offers; }\n",
"count": 2,
"filename": "redirects.conf"
}Netlify and Cloudflare Pages
Input
{
"redirects": [
[
"/old-page",
"/new-page"
]
],
"format": "netlify"
}Result
{
"text": "/old-page /new-page 301\n",
"count": 1,
"filename": "_redirects"
}Questions
- Where do the rules go?
- Apache: in the .htaccess file at the site root. Nginx: inside the server { } block. Netlify and Cloudflare Pages: in a file named _redirects in the published folder.
- Do the rules match the exact address?
- Yes. Each rule matches that one path, not everything beneath it. Query strings (the part after ?) are not part of the match.
- 301 or 302?
- Use 301 when the move is permanent so search engines transfer ranking to the new address. Use 302 for short-term moves.
Related tools
- robots.txt generatorBuild a robots.txt: allow or block all crawlers, add your own rules, block AI crawlers and list sitemaps.
robots-txt-generate - XML sitemap generatorBuild a valid XML sitemap from a list of page addresses, with optional last-modified date, frequency and priority.
sitemap-generate - .gitignore generatorBuild a .gitignore for the languages, editors and operating systems you use, merged without duplicates.
gitignore-generate - ASCII banner text generatorTurn short text into large five-line banner letters for terminals, READMEs, logs and code comments.
ascii-banner - ASCII table generatorRender headers and rows as a box-drawing or plain ASCII table for terminals, logs and code comments.
ascii-table - Background pattern generatorMake seamless SVG background patterns (dots, grid, stripes, checker or waves) with your colours and scale.
pattern-image