Created
July 18, 2020 20:48
-
-
Save mhajder/c182bb8cda3a93f408b9e922d2f15ad3 to your computer and use it in GitHub Desktop.
Redirect to the main domain from subdomains.
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8" /> | |
</head> | |
<body> | |
<script> | |
function getDomainName(hostName) { | |
return hostName.substring(hostName.lastIndexOf(".", hostName.lastIndexOf(".") - 1) + 1); | |
} | |
setTimeout(function () { | |
location.href = "http://" + getDomainName(window.location.hostname); | |
}, 0) | |
throw 404; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment