fix 404 redirect

Signed-off-by: Jess Frazelle <acidburn@google.com>
pull/1446/head
Jess Frazelle 2016-10-12 14:17:27 -07:00
parent bd6809a527
commit cbb4d33b3e
No known key found for this signature in database
GPG Key ID: 18F3685C0022BFF3
2 changed files with 62 additions and 61 deletions

63
404.md
View File

@ -3,66 +3,7 @@ layout: docwithnav
title: 404 Error!
permalink: /404.html
---
<script language="JavaScript">
$( document ).ready(function() {
var oldURLs=["/README.md","/README.html",".html",".md","/v1.1/","/v1.0/"];
var fwdDirs=["examples/","cluster/","docs/devel","docs/design"];
var doRedirect = false;
var notHere = false;
var forwardingURL=window.location.href;
if (forwardingURL.indexOf("third_party/swagger-ui") > -1)
{
notHere = true;
window.location.replace("http://kubernetes.io/kubernetes/third_party/swagger-ui/");
}
if (forwardingURL.indexOf("resource-quota") > -1)
{
notHere = true;
window.location.replace("http://kubernetes.io/docs/admin/resourcequota/");
}
if (forwardingURL.indexOf("horizontal-pod-autoscaler") > -1)
{
notHere = true;
window.location.replace("http://kubernetes.io/docs/user-guide/horizontal-pod-autoscaling/");
}
if (forwardingURL.indexOf("docs/roadmap") > -1)
{
notHere = true;
window.location.replace("https://github.com/kubernetes/kubernetes/milestones/");
}
if (forwardingURL.indexOf("api-ref/") > -1)
{
notHere = true;
window.location.replace("http://kubernetes.io/docs/api/");
}
if (forwardingURL.indexOf("docs/user-guide/overview") > -1)
{
notHere = true;
window.location.replace("http://kubernetes.io/docs/whatisk8s/");
}
for (i=0;i<fwdDirs.length;i++) {
if (forwardingURL.indexOf(fwdDirs[i]) > -1)
{
var urlPieces = forwardingURL.split(fwdDirs[i]);
var newURL = "https://github.com/kubernetes/kubernetes/tree/{{page.githubbranch}}/" + fwdDirs[i] + urlPieces[1];
notHere = true;
window.location.replace(newURL);
}
}
if (!notHere) {
for (i=0;i<oldURLs.length;i++) {
if (forwardingURL.indexOf(oldURLs[i]) > -1)
{
doRedirect=true;
forwardingURL=forwardingURL.replace(oldURLs[i],"/");
}
}
if (doRedirect)
{
window.location.replace(forwardingURL);
};
}
});
</script>
<script src="/js/redirects.js"></script>
Sorry, this page was not found. :(

60
js/redirects.js Normal file
View File

@ -0,0 +1,60 @@
$( document ).ready(function() {
var oldURLs=["/README.md","/README.html",".html",".md","/v1.1/","/v1.0/"];
var fwdDirs=["examples/","cluster/","docs/devel","docs/design"];
var doRedirect = false;
var notHere = false;
var forwardingURL=window.location.href;
var redirects = [{
"from": "third_party/swagger-ui",
"to": "http://kubernetes.io/kubernetes/third_party/swagger-ui/"
},
{
"from": "resource-quota",
"to": "http://kubernetes.io/docs/admin/resourcequota/"
},
{
"from": "horizontal-pod-autoscaler",
"to": "http://kubernetes.io/docs/user-guide/horizontal-pod-autoscaling/"
},
{
"from": "docs/roadmap",
"to": "https://github.com/kubernetes/kubernetes/milestones/"
},
{
"from": "api-ref/",
"to": "https://github.com/kubernetes/kubernetes/milestones/"
},
{
"from": "docs/user-guide/overview",
"to": "http://kubernetes.io/docs/whatisk8s/"
}];
for (i=0;i<redirects.length;i++) {
if (forwardingURL.indexOf(redirects[i].from) > -1){
notHere = true;
window.location.replace(redirects[i].to);
}
}
for (i=0;i<fwdDirs.length;i++) {
if (forwardingURL.indexOf(fwdDirs[i]) > -1){
var urlPieces = forwardingURL.split(fwdDirs[i]);
var newURL = "https://github.com/kubernetes/kubernetes/tree/{{page.githubbranch}}/" + fwdDirs[i] + urlPieces[1];
notHere = true;
window.location.replace(newURL);
}
}
if (!notHere) {
for (i=0;i<oldURLs.length;i++) {
if (forwardingURL.indexOf(oldURLs[i]) > -1 &&
forwardingURL.indexOf("404.html") < 0){
doRedirect=true;
forwardingURL=forwardingURL.replace(oldURLs[i],"/");
}
}
if (doRedirect){
window.location.replace(forwardingURL);
};
}
});