Socialify

Folder ..

Viewing not_found.html
27 lines (23 loc) • 677.0 B

 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
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
  </head>
  <script>
    const path = window.location.pathname;
    const isRoot = path === "/" || path === "/index" || path === "/not_found";

    // redirect to root with path parameter
    const otherQueryParams = window.location.search;
    let newPath = "/";

    if (otherQueryParams) {
      newPath += otherQueryParams;
    }

    if (!isRoot && otherQueryParams) {
      newPath += "&path=" + path;
    } else if (!isRoot) {
      newPath += "?path=" + path;
    }

    window.location.href = newPath;
  </script>
</html>