Is there a way if file not exist to server another app-*.js
file in other folder, example:
Go to URL: http://www.example.com/assets/build/app/app-48fee50a26.js
I am getting the following error message:
[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:""
I want to serve instead any other js file in the same folder /var/app/assets/build/app/
, but the name of the other file can constantly change, for example app-62a5962b0a11.js
. I was thinking about app\-(.*)\.js
.
all the examples below does not work:
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;
}
}