").insertAfter($("#main-content")); $("#main-content").hide() console.log("404 parser: "); var parser = document.createElement('a'); parser.href = requestUrl;requestUrl = parser.pathname; if(!parser.pathname.startsWith("/")){ console.log("No slash");requestUrl = "/" + requestUrl ;} console.log("404 parser: " + requestUrl); $.getJSON("/_api/web/Lists/getByTitle('Custom404')/items?$filter=OldURL eq '" + requestUrl + "'", function(data) { if (data && (data.value.length > 0)) { console.log(data.value[0]["NewURL"]); window.location.replace(data.value[0]["NewURL"]); } else { $("#main-content").show() $("#Custom404Loading").hide() } }); }})();
See Also
Frequently Asked Questions