如何重定向到以“/admin”开头的 url 重定向到/admin/index.html(单页应用程序)和另一个页面重定向到/index.html(其他单页应用程序)。
我的 nginx.conf 在这里
location / {
if ( $allowed = "deny" ) { return 403; }
try_files $uri /index.html;
}
location /admin {
alias /usr/share/nginx/html/admin;
}
这是有效的,但多级 url 重定向到 503 错误。
示例:获取/admin/questions/1 ->失败 503
示例:获取/admin/questions -> 失败 503
示例获取/admin -> 确定
最佳答案
我解决了。
默认配置文件:
root /usr/share/nginx/html;
index index.html;
location ~ ^/admin {
try_files $uri /admin/index.html;
}
location / {
try_files $uri /index.html;
}
关于regex - Nginx 多个 "Single Page App"路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40358943/