我有以下条件
(1) 如果我访问https://example.com 如果转到登录页面。
(2) 如果我访问 https://www.example.com 相同 它进入登录页面
现在我从 https://example.com 登录它重定向到仪表板页面,这很好。 当我再次访问 https://example.com 时它将我重定向到仪表板页面。
现在的问题 当我访问 https//www.example.com 时它重定向到登录页面。
这意味着我可以登录两个 session
1) https://example.com 2) https://www.example.com 在同一个浏览器上。 ?
请问如何处理这个问题。
我也在使用 http 重定向。
http.createServer(function (req, res) {
res.writeHead(301, { "Location": "https://www." + req.headers['host'] + req.url });
res.end();
}).listen(80);
var secureServer = https.createServer(sslOptions,app).listen(443, function(err,result){
console.log("Express server listening on port : 443");
console.log("Mode : " + app.get('mode'));
});
有什么建议吗?
谢谢
最佳答案
只是不要在多个主机名上托管您的网站。选择一个是规范的并将来自另一个的所有请求重定向(使用 301
HTTP 响应)到它。
关于javascript - www 和非 www 的 Nodejs session 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33185096/