如果文件不存在,有没有办法app-*.js
在其他文件夹中服务器另一个文件,例如:
转到网址:http ://www.example.com/assets/build/app/app-48fee50a26.js
我收到以下错误消息:
[error] 17788#17788: *1 open() "/var/app/assets/build/app/app-48fee50a26.js" failed (2: No such file or directory), client: , server: , request: "GET /assets/build/app/app-48fee50a26.js HTTP/1.1", host:""
我想在同一文件夹中提供任何其他 js 文件/var/app/assets/build/app/
,但其他文件的名称可以不断更改,例如app-62a5962b0a11.js
. 我在想app\-(.*)\.js
。
以下所有示例均无效:
server {
listen 80 default_server;
root /var/app;
location /assets/build/app/app\-(.*)\.js {
try_files $uri $uri/ /assets/build/app/app\-(.*)\.js;
}
}
server {
listen 80 default_server;
root /var/app;
location /assets/build/app/app\-(.*)\.js {
try_files $uri $uri/ /var/app/assets/build/app/app\-(.*)\.js;
}
}
Also not working without regex to the location of the other file.
server {
listen 80 default_server;
root /var/app;
location /assets/build/app/app\-(.*)\.js {
try_files $uri $uri/ /var/app/assets/build/app/app-62a5962b0a11.js;
}
}
server {
listen 80 default_server;
root /var/app;
location /assets/build/app/app\-(.*)\.js {
try_files $uri $uri/ /assets/build/app/app-62a5962b0a11.js;
}
}