如何在客户端脚本中从http切换到https。请勿更改网址否则。它在https中不应该做任何事情。服务器对http和https的回复相同。我需要原始网址的其余部分保持不变。
http://example.com --> https://example.com
http://example.com/a --> https://example.com/a
http://example.com/b --> https://example.com/b
答案 0 :(得分:1)
您可以使用javascript window.location.href属性重新加载https网址
// current url: http://example.
if(window.location.href.substr(0,5) !== 'https'){
window.location.href = window.location.href.replace('http', 'https');
} // new url: https://example.