尝试返回自定义404页而不是nginx 404默认页
我用Vue.js做了SPA 我在客户端以这种方式处理404:尝试返回自定义404页而不是nginx 404默认页,nginx,vue.js,Nginx,Vue.js,我用Vue.js做了SPA 我在客户端以这种方式处理404: //at the end of router { path: '/404', name: 'not-found', component: () => import(...) }, { path: '*', redirect: '/404' } 问题:当我试图访问我的开发环境中一些不存在的页面时,我得到的是nginx默认404页面,而不是Vue页面 Nginx配置的部分内容: server { ind
//at the end of router
{
path: '/404',
name: 'not-found',
component: () => import(...)
},
{
path: '*',
redirect: '/404'
}
问题:当我试图访问我的开发环境中一些不存在的页面时,我得到的是nginx默认404页面,而不是Vue页面
Nginx配置的部分内容:
server {
index index.html;
location / {
try_files $uri $uri/ =404;
}
//ssl config managed by Certbot
}
server {
if ($host = <...>) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name <...>;
listen 80;
}
server {
if ($host = <...>) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name <...>;
listen 80;
return 404; # managed by Certbot
}
反而
location / {
try_files $uri $uri/ =404;
}
,没有帮助。更改了
try\u files$uri$uri/=404
totry_files$uri$uri//index.html代码>
location / {
try_files $uri $uri/ =404;
}