Reputation: 725
I understand that i should put this code in order to make HTML5 History fallback:
location / {
try_files $uri $uri/ /index.html;
}
https://router.vuejs.org/en/essentials/history-mode.html
but to which file? tried search google, nothing works, put above code in /etc/nginx/nginx.conf will make nginx not working.
im using vagrant Homestead for laravel.
please help.
Upvotes: 5
Views: 7964
Reputation: 696
If you were looking for the location of the NGINX config file:
/etc/nginx/nginx.conf
./etc/nginx/conf.d/*.conf
into its http
block.server
block, you can overwrite /etc/nginx/conf.d/default.conf
or add your own .conf
file there.Upvotes: 3
Reputation: 725
Finally, i get nginx work with html5 fallback.
open /etc/nginx/site-available/homestead.app, or any domain your specified in your homestead.yaml file.
put/replace "location" section with
location / {
try_files $uri $uri/ /index.php;
}
then save, and open laravel web.php (router). put this code:
Route::get('/{vue?}/{vue2?}/{vue3?}', function () {
// return view('welcome');
if ( ! request()->ajax() ) {
return view('index');
}
});
above code prevent laravel to returning error 404. now vue html5 history fallback works without # sign.
thanks everyone for trying to help, without you guys i may not have any idea to resolve this issue.
Upvotes: 0
Reputation:
That is an entry for the nginx.conf
file, located at
/etc/nginx/nginx.conf
Add this to config:
location / {
try_files $uri /index.html;
}
Upvotes: -1
Reputation: 3428
Put configuration in /etc/nginx/nginx.conf
server {
location / {
try_files $uri $uri/ /index.html;
}
}
Upvotes: 2