Vue SPA, redirect rules

I have successfully deployed a vuejs application to netlify.

The SPA has its own routing, so no server side routing is needed. I know that the Apache has rewrite/redirect rules, how does the netlify server handle this?

Thanks, iago

Hey @iago

This is done via rewrite. Check out the History pushstate and SPA documentation as well as the following support guide.

In short create a _redirects file in the project public directory with

/*   /index.html   200

thanks for the answer. I’ve already found that. However, I have no idea where my public directory is.
I don’t see any directory access on my netlify control panel.
Could you give me just one hint? Thanks!

It must be somewhere in the build & deploy section… I hope so… no idea to be honest…

The public directory in your project. Here’s an example: vue-netlify-basic/public at main · coelmay/vue-netlify-basic · GitHub

So I must push the _redirects file to github?.. If yes, will this automatically sync with netlify?

Yes the file needs pushing to GitHub. If you have GitHub connected to Netlify, and builds are enabled, then Netlify will detect this change and rebuild your site.

1 Like