Created
April 16, 2018 23:49
-
-
Save miguelmota/235da9f6492eb78440b8cbf8ea0e3644 to your computer and use it in GitHub Desktop.
JavasScript redirect to HTTPS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
var url = window.location.href.replace(/http:\/\/(?:www\.)?(mywebsite\.com|otherdomain\.io)/gi, 'https://mywebsite.com'); | |
url !== window.location.href && (window.location.href = url) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment