Skip to content

Latest commit

 

History

History
63 lines (62 loc) · 2.15 KB

404.md

File metadata and controls

63 lines (62 loc) · 2.15 KB
layout title permalink
404 Redirector
/404.html
<script language="JavaScript"> function doFwd() { var forwardingURL=window.location.pathname; if (forwardingURL.charAt(forwardingURL.length) != "/") forwardingURL += "/"; var gonnaFwd = false; var newURL = ""; console.log(forwardingURL); {% for item in site.data.redirects %} var redirectVal = {{ item | jsonify }}; if (forwardingURL.indexOf(redirectVal.source) > -1) { console.log("Found via CSV @ ", redirectVal.source, redirectVal.destination); gonnaFwd = true; newURL = forwardingURL.replace(redirectVal.source,redirectVal.destination); } {% endfor %} {% for page in site.pages %}{% if page.aliases %} var aliases = {{ page.aliases | jsonify }}; if( Object.prototype.toString.call( aliases ) === '[object Array]' ) { // aliases is an array, therefore, there are multiple aliases for (i=0; i< aliases.length; i++) { if (forwardingURL.indexOf(aliases[i]) > -1) { console.log("Found via Page Aliases on a multi-alias page @", "{{ page.url }}", aliases[i]) gonnaFwd = true; newURL = "{{ page.url }}"; } } } else { // only one alias for this page. if (forwardingURL.indexOf(aliases) > -1) { console.log("Found via Page Aliases on a single-alias page @", forwardingURL.indexOf(aliases[i]), aliases[i]) gonnaFwd = true; newURL = "{{ page.url }}"; } } {% endif %}{% endfor %} {% for item in site.data.docsarchive.docker-compose %} if (forwardingURL.indexOf("/{{ item[0] }}") > -1) { console.log("Found via Docker Compose file for Acrhive") gonnaFwd = true; newURL = forwardingURL.replace("/{{ item[0] }}","{{ page.archiveserver }}:{{ item[1].ports[0] | replace:':4000','' }}"); }{% endfor %} if (gonnaFwd) { console.log("Forwarding to: " + newURL); //window.location.replace(newURL); document.write('') } else { //window.location.replace("/sorry/#" + forwardingURL); document.write('') } } window.onload = doFwd; </script>