404.html 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Single Page Apps for GitHub Pages</title>
  6. <script type="text/javascript">
  7. // Single Page Apps for GitHub Pages
  8. // MIT License
  9. // https://github.com/rafgraph/spa-github-pages
  10. // This script takes the current url and converts the path and query
  11. // string into just a query string, and then redirects the browser
  12. // to the new url with only a query string and hash fragment,
  13. // e.g. https://www.foo.tld/one/two?a=b&c=d#qwe, becomes
  14. // https://www.foo.tld/?/one/two&a=b~and~c=d#qwe
  15. // Note: this 404.html file must be at least 512 bytes for it to work
  16. // with Internet Explorer (it is currently > 512 bytes)
  17. // If you're creating a Project Pages site and NOT using a custom domain,
  18. // then set pathSegmentsToKeep to 1 (enterprise users may need to set it to > 1).
  19. // This way the code will only replace the route part of the path, and not
  20. // the real directory in which the app resides, for example:
  21. // https://username.github.io/repo-name/one/two?a=b&c=d#qwe becomes
  22. // https://username.github.io/repo-name/?/one/two&a=b~and~c=d#qwe
  23. // Otherwise, leave pathSegmentsToKeep as 0.
  24. var pathSegmentsToKeep = 0;
  25. var l = window.location;
  26. l.replace(
  27. l.protocol +
  28. '//' +
  29. l.hostname +
  30. (l.port ? ':' + l.port : '') +
  31. l.pathname
  32. .split('/')
  33. .slice(0, 1 + pathSegmentsToKeep)
  34. .join('/') +
  35. '/?/' +
  36. l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') +
  37. (l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') +
  38. l.hash,
  39. );
  40. </script>
  41. </head>
  42. <body></body>
  43. </html>