-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path404.html
More file actions
41 lines (41 loc) · 1.59 KB
/
Copy path404.html
File metadata and controls
41 lines (41 loc) · 1.59 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
35
36
37
38
39
40
41
---
permalink: /404.html
layout: ~
---
{% comment %}
GitHub Pages doesn't let us configure redirects, so all redirecting has to be clientside.
1. This uses javascript to avoid cluttering the navigation history.
If path is /portal/, try to preserve the rest of the URL when redirecting.
2. If javascript is not available, just redirect immediately to catch-all /we-moved
3. If the browser blocks redirects, then the user has to redirect themselves??
{% endcomment -%}
<!DOCTYPE html>
<html lang="en">
<head>
<script>
if (!window.location.pathname.startsWith('/portal/'))
window.location.replace("/we-moved");
else {
let url = new URL(window.location.href);
url.hostname = 'portal.idigbio.org';
var urlRedirectTarget = url.href;
window.location.replace(urlRedirectTarget);
}
</script>
<noscript><meta http-equiv="refresh" content="0;url=/we-moved" /></noscript>
</head>
<body>
<p><span id="body-msg-pre">The content you have requested has been moved. </span><a id="body-link" href="/we-moved">Learn more about available resources</a><span id="body-link-post"> if you have not been automatically redirected.</span></p>
<script>
// If redirect fails for some reason but javascript is allowed
// not sure why I'm over-engineering this now that I think about it
if (window.location.pathname.startsWith('/portal/')) {
Object.assign(document.querySelector('#body-link'), {
href: urlRedirectTarget,
textContent: 'Go to iDigBio Portal.',
});
document.querySelector('#body-link-post').textContent = '';
}
</script>
</body>
</html>