Redirecting your SPA on Netlify

In our project this week we built a single-page application. We wrote a custom “missing” page to display when the user routes to a non-existent page and gets a 404 HTTP response. However, when we deployed on Netlify the user gets server the default Netlify missing page which isn’t customised.

In the Netlify docs, the method to redirect routes on your application is to add a file with the name _redirects which outlines the rules for your paths.

Having the below in your _redirects file will redirect any non-existing paths to your missing.html page with a status code of 404:
/* /missing.html 404

Having the below in your _redirects file will redirect any non-existing paths to your index.html page with a status code of 200:
/* /index.html 200