Skip to content

redirect()

app.redirect(from, to, [status])
app.redirect(map)
app.redirect(entries)
NameTypeDescription
fromstringSource path (e.g., '/old').
tostringTarget URL or path.
statusnumberHTTP status code (default: 302).
NameTypeDescription
mapObject{ from: to } pairs. All use status 302.
NameTypeDescription
entriesArrayArray of { from, to, status? } objects.

Returns: Array of registered entries [{ path, to, status }] or null.

// Single redirect
app.redirect("/old", "/new");
// Permanent redirect
app.redirect("/legacy", "/modern", 301);
// Map syntax
app.redirect({
"/old-page": "/new-page",
"/deprecated": "/current",
});
// Array syntax with per-entry status
app.redirect([
{ from: "/a", to: "/b" },
{ from: "/c", to: "/d", status: 301 },
]);