layout | subtitle | comments | permalink |
---|---|---|---|
page |
404 |
true |
/404.html |
Link rot stinks, amirite? It's tempting to blame whoever sent you this missing page, but really it's my fault, not theirs, for moving the page. Unless it was a typo. Or you were just guessing URLs to see if I had anything parked there.
<script src="https://archive.org/web/wb404.js"></script> <script> var allposts = []; function redirectToCorrectPage() { console.log("Unable to find page. Trying other URL cases."); {% for post in site.pages %} allposts.push("{{ post.url }}"); {% endfor %} var url = window.location.pathname; // strip trailing / if (url.slice(-1) === "/") { url = url.slice(0, -1); } var allpostsUpperCase = allposts.map(function(value) { // strip trailing / if (value.slice(-1) === "/") { value = value.slice(0, -1); } return value.toUpperCase(); }); console.log("Looking for "+url.toUpperCase() + " in "+allpostsUpperCase); var i = allpostsUpperCase.indexOf(url.toUpperCase()); if (i != -1) { console.log(allposts[i]); window.location = allposts[i]; } } window.onload = redirectToCorrectPage; </script>