Skip to content

Instantly share code, notes, and snippets.

@robingi
Last active May 30, 2017 09:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robingi/c06004bb66a54eed7775b86b45d00150 to your computer and use it in GitHub Desktop.
Save robingi/c06004bb66a54eed7775b86b45d00150 to your computer and use it in GitHub Desktop.
Non https and non www redirect
/**
Non https and non www redirect
*/
var url = document.URL;
var splitByDot = url.split('.');
var splitBySlash = url.split('//');
if(url.indexOf('https') === -1 && url.indexOf('www') === -1) {
if(!splitByDot[2]) {
// www einsetzen falls nicht vorhanden und keine subdomain ist
url = 'https://www.' + splitBySlash[1];
} else {
// falls www oder subdomain vorhanden, nur https vorsetzen
url = 'https://' + splitBySlash[1];
}
}
// window.location = url; // weiterleitung zur richtigen url
{"view":"separate","fontsize":"100","seethrough":"","codespector_bootstrap":"","codespector_jquery":"","page":"all"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment