从 http://重定向到 https:// [英] Redirect from http:// to https://
本文介绍了从 http://重定向到 https://的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将用户从我的 http 网站重定向到 https 网站,是否有像元或 JavaScript 或 html 这样的网站来执行此操作,我的网站有一个 http 服务器以及一个安全版本.
I want to redirect users from my http website to https site is there like a meta or JavaScript or html to do this my site has a http server as well as a secure version.
推荐答案
作为快速修复,您可以这样做:
As a quick-fix you can do it like this:
if(window.location.protocol != 'https:') {
location.href = location.href.replace("http://", "https://");
}
但我建议您使用网络服务器中的可用方法来完成
But I recommend you to do it using the available method in your web server
这篇关于从 http://重定向到 https://的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文