permalink /404.html <script> // remove first slash char var path = window.location.pathname.substr(1); if (path[path.length-1] == "/") { path = path.substr(0, path.length - 1); } path = path.substr(path.indexOf("/")); // prepend to path pathV3 = '/docs/v3' + path; path = '/docs' + path; var URL = window.location.origin + path var URLV3 = window.location.origin + pathV3 //console.log(URL); //console.log(URLV3); var requestedPageExists = function(resourceUrl){ var http = new XMLHttpRequest(); http.open('GET', resourceUrl, false); http.send(); return http.status != 404; } if(requestedPageExists(URL)) { window.location.replace(URL); } else { if(requestedPageExists(URLV3)) { window.location.replace(URLV3); } else { window.location.replace(window.location.origin + '/not-found'); }; }; </script>