-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy path404.html
More file actions
34 lines (31 loc) · 1.06 KB
/
404.html
File metadata and controls
34 lines (31 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Redirecting...</title>
<script>
// GitHub Pages SPA 重定向支持
// 支持 github.io 子目录部署和自定义域名
(function() {
var l = window.location;
var pathname = l.pathname;
// 保存当前路径用于 SPA 恢复
sessionStorage.setItem('github_pages_redirect', pathname + l.search + l.hash);
// 判断是否是 GitHub Pages 子目录部署 (xxx.github.io/repo-name/)
if (l.hostname.endsWith('github.io')) {
var repo = pathname.split('/')[1];
if (repo) {
// 重定向到仓库根路径
l.replace(l.protocol + '//' + l.hostname + '/' + repo + '/');
return;
}
}
// 自定义域名或根目录部署 - 直接重定向到根路径
l.replace(l.protocol + '//' + l.hostname + '/');
})();
</script>
</head>
<body>
<p>Redirecting...</p>
</body>
</html>