用新的URL重新运行路线

我有一个小的networking服务器,作为旧的URL优化器,它匹配旧的url和redirect到新的更好的SEO优化的url。

其中一个url是这样的:

login.php?return=http://example.com/index.php?page=protected_page 

现在优化服务后, http://example.com/index.php? /page/protected_page/现在只是/page/protected_page/和内部的authentication,所以当然我把一个像

 'login.php': function(req, res, next) { if (req.query.return) { res.redirect(req.query.return); } } 'index.php': function(req, res, next) { if (req.query.page === 'protected_page') { // redirect to proper seo page without index.php res.redirect(...); } } 

在这种情况下会发生什么,首先浏览器将被redirect到req.query.return的url,然后express将响应index.php上匹配的新请求。 这是可以的,但是如果基础架构复杂,客户端浏览器需要一些时间才能发出新的请求(如果访问网站的人在技术上远离服务器,甚至可能需要0.5-1秒)。

任何方式我可以采取req.query.return并有像app.processNewUrl(req.query.return)