function redirectToSecure() { var strCurrentURL = window.location.href; if(strCurrentURL.indexOf("https:") == -1) { strCurrentURL = strCurrentURL.replace("http:", "https:"); window.location.href = strCurrentURL; } } redirectToSecure();