使用nginx部署vue项目一直报错,这个折腾我好几天了,哪位大神知道是什么原因吗?
下面是我的nginx配置:
server {
index index.html index.htm;
server_name ***;
root /home/u/depolyfile/deploy;
listen 80;
location / {
try_files $uri $uri/ @rewrites;
}
location @rewrites {
rewrite ^(.+)$ /index.html last;
}
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
expires max;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
}
vue的router部分:
import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'
import DefaultPage from '@/components/DefaultPage'
Vue.use(Router)
export default new Router({
mode: 'history',
routes: [
{
path: '/',
name: 'HelloWorld',
component: HelloWorld
},
{
path: '*',
name: 'DefaultPage',
component: DefaultPage
}
]
})
nginx错误信息:
2018/07/02 14:26:01 [error] 5#5: *25 rewrite or internal redirection cycle while redirect to named location "@rewrites"
这一段不需要吧