Add _redirects file to root path for Vue SPA hosted on Netlify

后端 未结 5 919
难免孤独
难免孤独 2021-01-31 05:28

I\'m developing a Single Page App using Vue CLI and want history pushstate to work so I get clean URLs.

I have to follow this: https://www.netlify.com/docs/redirects/#hi

5条回答
  •  Happy的楠姐
    2021-01-31 05:46

    You could also just use the netlify.toml file which tends to be a bit cleaner. Just put this in the file to get the redirect you were looking for:

    # The following redirect is intended for use with most SPA's that handles routing internally.
    [[redirects]]
      from = "/*"
      to = "/index.html"
      status = 200
    

    You can find more info about the netlify.toml file here.

提交回复
热议问题