mirror of https://github.com/docker/docs.git
60 lines
1.9 KiB
Markdown
60 lines
1.9 KiB
Markdown
---
|
|
layout: null
|
|
title: 404 Redirector
|
|
permalink: /404.html
|
|
---
|
|
|
|
<script language="JavaScript">
|
|
function doFwd() {
|
|
var forwardingURL=window.location.href;
|
|
var domainName = window.location.hostname;
|
|
var portNumber = window.location.port;
|
|
var gonnaFwd = false;
|
|
var newURL = "";
|
|
console.log(forwardingURL);
|
|
{% 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! ", forwardingURL.indexOf(aliases[i]), aliases[i])
|
|
gonnaFwd = true;
|
|
newURL = "{{ page.url }}";
|
|
}
|
|
}
|
|
} else {
|
|
// only one alias for this page.
|
|
if (forwardingURL.indexOf(aliases) > -1)
|
|
{
|
|
console.log("Found! ", 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)
|
|
{
|
|
gonnaFwd = true;
|
|
if(portNumber.length > 0) {
|
|
// there is a port number in the location; make sure to replace it
|
|
newURL = forwardingURL.replace(domainName + ":"+ portNumber +"/{{ item[0] }}","{{ page.archiveserver }}:{{ item[1].ports[0] | replace:':4000','' }}");
|
|
} else {
|
|
// no port number in the location; just foward them on
|
|
newURL = forwardingURL.replace(domainName + "/{{ item[0] }}","{{ page.archiveserver }}:{{ item[1].ports[0] | replace:':4000','' }}");
|
|
}
|
|
newURL = newURL.replace("https:","http:")
|
|
}{% endfor %}
|
|
if (gonnaFwd) {
|
|
console.log("Forwarding to: " + newURL);
|
|
window.location.replace(newURL);
|
|
} else {
|
|
window.location.replace("/sorry/#" + forwardingURL);
|
|
}
|
|
}
|
|
window.onload = doFwd;
|
|
</script>
|