【发布时间】:2018-03-09 20:00:31
【问题描述】:
我有一个 node.js 网站,它将替换现有网站。新站点中的某些 URL 与旧站点中的不同,因此我需要为这些设置 301 重定向。
目前我正在使用以下方法重新路由特定页面:
app.get('contact-us', (req, res, next) => {
res.redirect(301, 'http://www.example.com/contact');
});
但是有没有办法根据模式重新路由?例如在旧网站上我有 /products/id/product-name 我需要重新路由到 /catalogue/id/product-name
【问题讨论】:
标签: node.js express http-status-code-301