let rep = "" let loc = window.location.hostname let parts = loc.split('.') let end = parts[parts.length -1] loc = window.location.protocol + '//' + parts[parts.length -2] + '.' + end let search = '' if(window.location.search){ search = window.location.search } else { search = '?' } if(window.location.search.includes('redirect=true')){ window.location.replace(loc) } if(!window.location.pathname.endsWith('/')) { rep = `${loc}${ window.location.pathname.toLowerCase()}${search}redirect=true` window.location.replace(loc) }else if(window.location.pathname.endsWith('/')){ rep = `${loc}${window.location.pathname.substr(0, window.location.pathname.lastIndexOf('/')).toLowerCase()}.html${search}redirect=true` window.location.replace(rep) }