Skip to content

Commit b371cee

Browse files
committed
404 redirect
1 parent b5e4f95 commit b371cee

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

public/404.html

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!DOCTYPE html>
2+
<html lang="zh-CN">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Redirecting...</title>
8+
<script type="text/javascript">
9+
// Redirect all GitHub Pages 404 requests back to the SPA entry point.
10+
// Based on https://github.com/rafgraph/spa-github-pages
11+
(() => {
12+
var redirect = sessionStorage.getItem("spa-redirect");
13+
if (redirect) {
14+
sessionStorage.removeItem("spa-redirect");
15+
window.location.replace(redirect);
16+
return;
17+
}
18+
19+
var l = window.location;
20+
var pathname = l.pathname;
21+
var search = l.search;
22+
var hash = l.hash;
23+
24+
sessionStorage.setItem(
25+
"spa-redirect",
26+
pathname.replace(/^(\/)/, "") + search + hash
27+
);
28+
29+
window.location.replace(l.origin + "/?redirect=true");
30+
})();
31+
</script>
32+
</head>
33+
<body>
34+
<p>Redirecting...</p>
35+
</body>
36+
</html>

0 commit comments

Comments
 (0)