redirect()
Signature
Section titled “Signature”app.redirect(from, to, [status])app.redirect(map)app.redirect(entries)Parameters
Section titled “Parameters”Three-argument form
Section titled “Three-argument form”| Name | Type | Description |
|---|---|---|
from | string | Source path (e.g., '/old'). |
to | string | Target URL or path. |
status | number | HTTP status code (default: 302). |
Map form
Section titled “Map form”| Name | Type | Description |
|---|---|---|
map | Object | { from: to } pairs. All use status 302. |
Array form
Section titled “Array form”| Name | Type | Description |
|---|---|---|
entries | Array | Array of { from, to, status? } objects. |
Returns: Array of registered entries [{ path, to, status }] or null.
Examples
Section titled “Examples”// Single redirectapp.redirect("/old", "/new");
// Permanent redirectapp.redirect("/legacy", "/modern", 301);
// Map syntaxapp.redirect({ "/old-page": "/new-page", "/deprecated": "/current",});
// Array syntax with per-entry statusapp.redirect([ { from: "/a", to: "/b" }, { from: "/c", to: "/d", status: 301 },]);