if (document.location.protocol=="http:" &&
{
//http redirect to https
var new_url = "https://" + document.location.hostname + document.location.pathname + document.location.search;
document.location = new_url;
}
或者(带有域名跳转)
<script language='javascript'>
if (document.location.protocol=="http:" &&
(document.location.hostname=='cd-sw.com' || document.location.hostname=='www.cd-sw.com')) {
//http redirect to https
var new_url = "https://" + document.location.hostname + document.location.pathname + document.location.search;
document.location = new_url;
}
发表评论