mirror of https://github.com/docker/docs.git
Redirect logic
This commit is contained in:
parent
cb3f6f04a1
commit
df9aff2877
17
404.md
17
404.md
|
@ -6,9 +6,8 @@ permalink: /404.html
|
|||
|
||||
<script language="JavaScript">
|
||||
function doFwd() {
|
||||
var forwardingURL=window.location.href;
|
||||
var domainName = window.location.hostname;
|
||||
var portNumber = window.location.port;
|
||||
var forwardingURL=window.location.pathname;
|
||||
if (forwardingURL.charAt(forwardingURL.length) != "/") forwardingURL += "/";
|
||||
var gonnaFwd = false;
|
||||
var newURL = "";
|
||||
console.log(forwardingURL);
|
||||
|
@ -51,20 +50,20 @@ function doFwd() {
|
|||
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','' }}");
|
||||
newURL = forwardingURL.replace("/{{ 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 = forwardingURL.replace("/{{ 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);
|
||||
document.write('<meta http-equiv="refresh" content="0; url=' + newURL + '">')
|
||||
//window.location.replace(newURL);
|
||||
//document.write('<meta http-equiv="refresh" content="0; url=' + newURL + '">')
|
||||
} else {
|
||||
window.location.replace("/sorry/#" + forwardingURL);
|
||||
document.write('<meta http-equiv="refresh" content="0; url=/sorry/#' + forwardingURL + '">')
|
||||
//window.location.replace("/sorry/#" + forwardingURL);
|
||||
//document.write('<meta http-equiv="refresh" content="0; url=/sorry/#' + forwardingURL + '">')
|
||||
}
|
||||
}
|
||||
window.onload = doFwd;
|
||||
|
|
Loading…
Reference in New Issue