Outline
In Angular apps, the Angular framework handles routing. By default, this will cause a 404 error when you refresh the Angular app and you're not on the main route. To overcome this, you can tell Netlify to redirect all requests to the root index.html
file. This will allow you to refresh your application on any page and not get a 404 page.
Add a _redirects
file to the root of your application, and make sure that the angular.json
file copies it into the built application as well. Push to master
and your site will redeploy. Test it out after pushing to make sure that everything is still working.
If you're not using Angular, just make sure that the _redirects
file is copied to the publish directory. As long as that file is copied to the root of the publish directory, it will work as expected.