nuxt项目部署到nginx
,已在nginx
配置
location / {
try_files $uri $uri/ /;
root html;
index index.html index.htm;
}
解决了因路由问题引起的404问题,但是只跳转到首页,并未根据路由的不同显示其他内容。
也就是说无论http://domain/xxx/5af
还是http://domain/xxx/6bf
都是显示的首页内容。
后面尝试过其他nginx配置
# one
location / {
try_files $uri $uri/ /index.html last;
root html;
index index.html index.htm;
}
# two
location / {
try_files $uri $uri/ @router;
index index.html;
}
location @router {
rewrite ^.*$ / last;
}
均以失败告终。
在locahost环境下,一切正常。所以不知道nginx配置哪里有问题,请大家指教。
作为刚入IT届的新人,对nginx理解不是很深入,非常感谢大家的帮助。
之前发现一个问题,当关闭nginx后还能正常访问,发现在进程中开启了多个nginx,后面按照Vue Router官方的教程配置nginx已经成功。https://router.vuejs.org/zh/g...