I have vue cli project deployed on ubuntu (apache2 server)
After vue router mode change, all pages besides index, are showing 404 page on reload.
I added .htaccess to /dist path where index.html is, but it still not working
I have no idea what else do to solve this issue.
Have anybody some idea?
here is my project dist folder
/home/admin/web/mali-nali.com/public_html/dist
.htaccess code in dist
RewriteEngine On
RewriteBase /
RewriteRule ^index.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
this is htacccess.madewithlove.be debuging info
RewriteEngine On RewriteEngine was now turned on
2 RewriteBase / Using / as the base for the rewrites.
3 RewriteRule ^index.html$ - [L] This rule was not met.
4 RewriteCond %{REQUEST_FILENAME} !-f This condition was met.
5 RewriteCond %{REQUEST_FILENAME} !-d This condition was met.
6 RewriteRule . /index.html [L] The new url is https://mali-nali.com/index.html
The tests are stopped because of the L in your RewriteRule options.
last route for all not exists pages
{path: '/*',component:FourohFour, name:'404'}
4
Answers
From https://router.vuejs.org/guide/essentials/history-mode.html#example-server-configurations
It appears like that’s what you’re missing.
In the root of your Vue project add a file called vue.config.js with the code below.
Then still in the root of your Vue project add a file called 404.html with the code below.
Then copy the 404.html file you created into the /dist folder.
I hope that helps you.
Set your publicPath option in vue.config.js:
Then, in the dist directory, create a .htaccess with contents like this:
Because the problem is as relevant today as it was then, here is a possible error why you get a 404 on a refresh of a SPA route.
If you use laravel and Vue SPA with the Vue Router you have to make sure that the web route is configured correctly.
This line should be in your web.php like this or similar:
web.php