why doesn't my 404.html redirect to index.html? #55673
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Someone suggested to place index.html content to 404.html. 404.html page serves as index.html when 404.html is displaced and will redirect to the path from route. In my case I only have one simple link "/donate". However, this doesn't work either. It still display github pages' `404 Read the full documentation for more information about using GitHub Pages.` , how to make github pages display my own 404.html? Is there a configuration for that? Thank you in advance! |
Beta Was this translation helpful? Give feedback.
-
finally solved the problem from stackoverflow . For vite react application, place the 404.html page at public folder, then add configuration to the vite.configure.js so that the 404.html will be place in dist folder after build. Saving you click the stackoverflow link, here is code: |
Beta Was this translation helpful? Give feedback.
finally solved the problem from stackoverflow . For vite react application, place the 404.html page at public folder, then add configuration to the vite.configure.js so that the 404.html will be place in dist folder after build. Saving you click the stackoverflow link, here is code:
<title>Page Not Found</title> <script> sessionStorage.redirect = location.href; </script> `, place this code to index.html at header section ` <script> (() => { const redirect = sessionStorage.redirect; delete sessionStorage.redirect; if (redirect && redirect !== location.href) { history.replaceState(null, null, redirect); } })(); </script>`, then at vite.configure.js, add this `export default defin…404.html
`