nginx配置的网页刷新 404
文章已阅读次
在配置中添加:
try_files $uri $uri/ /index.html; —解决页面刷新404问题
实例:
location / {
add_header 'Access-Control-Allow-Origin' *;
add_header 'Access-Control-Allow-Methods' 'GET,HEAD,OPTIONS,POST,PUT';
add_header 'Access-Control-Allow-Headers' 'DNT, X-Mx-ReqToken, Keep-Alive, User-Agent, X-Requested-With';
root html\VueWeb;
index index.html index.htm;
try_files $uri $uri/ /index.html; ---解决页面刷新404问题
location /api{
rewrite ^/api/(.*)$ /$1 break;
proxy_pass HTTP://localhost:5000;
}
}