Answer the question
In order to leave comments, you need to log in
What server settings are needed for SPA?
I have a Vue SPA application using mode: 'history' in VueRouter. Locally, everything goes well on "other villages". I uploaded it to the hosting, it gives a 404 error when switching to any other route (/about)
How can I make the hosting always give me my only page when switching to other routes?
Answer the question
In order to leave comments, you need to log in
Here is the documentation for VueRouter just for my question
https://router.vuejs.org/guide/essentials/history-...
Add to .htaccess to redirect to index.html
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
If you are using Laravel, you can route all requests through routes:
Route::get('{any}', function() {
return view('spa');
})->where('any', '.*');
Route::get('/api/v1/products', function() {
return 'some api handler...';
});
Route::get('{any}', function() {
return view('spa');
})->where('any', '.*');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question