Skip to content

Instantly share code, notes, and snippets.

@shepardm7
Created July 4, 2018 15:42
Show Gist options
  • Save shepardm7/c856e761e9d3203f29df2b5d3c56cd8b to your computer and use it in GitHub Desktop.
Save shepardm7/c856e761e9d3203f29df2b5d3c56cd8b to your computer and use it in GitHub Desktop.
How to automatically redirect http to https using javascript
var loc = window.location.href+'';
if (loc.indexOf('http://')==0){
window.location.href = loc.replace('http://','https://');
}
//Source: https://stackoverflow.com/questions/4954768/automatic-redirection-to-https
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment