Skip to content

Instantly share code, notes, and snippets.

@lkwatson
Created February 21, 2018 02:23
Show Gist options
  • Save lkwatson/8bd6b154b0902d358b54f9ea013cb9e4 to your computer and use it in GitHub Desktop.
Save lkwatson/8bd6b154b0902d358b54f9ea013cb9e4 to your computer and use it in GitHub Desktop.
Enforce HTTPS
if(window.location.host == "example.com") {
var host = "example.com";
if ((host == window.location.host) && (window.location.protocol != "https:")) {
window.location.protocol = "https";
}
}else{
var host = "www.example.com";
if ((host == window.location.host) && (window.location.protocol != "https:")) {
window.location.protocol = "https";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment