【发布时间】:2016-08-15 12:00:49
【问题描述】:
我想通过以下方式使用 nginx 路由我的请求
site.com/admin -> admin/index.html
admin/js/assets.js // the route locations have individual assets
site.com/112dw -> dist/index.html // alphanumeric regex
dist/css/assets.css
我有以下 nginx 配置
server {
listen 80
root /usr/share/nginx/html;
location /admin {
//alias /usr/share/nginx/html/admin/;
try_files $uri /admin/index.html; // changed based on answer below
}
location ~* /[a-zA-Z0-9].*$ { // rest of the routes
add_header 'Access-Control-Allow-Origin' '*';
//alias /usr/share/nginx/html/dist/;
try_files $uri /dist/index.html;
}
}
在我将配置更改为使用 try_files 后,我的静态资产没有被提供,因为 HTML 正在搜索上面的路径一目录。谁能指出我正确设置它?
【问题讨论】:
标签: nginx