Expressjs域名redirect在OpenShift上不起作用
我正在学习Nodejs并尝试讨论OpenShift,
我使用快递,这是在OpenShift实用工作我添加此代码,
//redirect domain to www.domain app.all(/.*/, function(req, res, next) { var host = req.header("host"); if (host.match(/^www\..*/i)) { next(); } else { res.redirect(301, "http://www." + host); } });
但是它在我的本地主机上工作,我只是想将mydomain.biz
redirect到www.mydomain.biz
非常感谢你
请将console.log req.header("host")
在openshift上,它必须是正则expression式/ /^www\..*/i
..*/ /^www\..*/i
。