I am hosting my vuejs project on apache server.
- init project
- setup router
- Build and hosted to apache server
const router = new VueRouter({
routes: Routes,
// relative: true,
mode: 'history'
});
This runs fine in local, but vue router breaks on server. Example
If I run http://example.com and go to http://exmaple.com/sub It works fine
but if I refresh the page It will throw 404 Error.
From the vue.js documentation page:
Apache
It seems its not your issue its
apache
.htaccess issue i guess, your local may have that file and your server don't have it.please once check it that, you also uploaded .htaccess to your server as its hidden file you may forgot to upload it.
if its not there you can check this reference help : https://router.vuejs.org/en/essentials/history-mode.html
and add your own .htaccess file if its not there.