How can i have location directive for all json files in all subfolders but if file is in root directory it should return 404.
/test.json - 404
/$anything/test.json - found
How can i have location directive for all json files in all subfolders but if file is in root directory it should return 404.
/test.json - 404
/$anything/test.json - found
Use a regular expression to match files in the root directory. Place the regular expression location
early in your configuration to avoid other regular expression locations overriding it.
For example:
root /path/to/files;
location / {
try_files $uri $uri/ =404;
}
location ~ ^/[^.]*\.json$ {
return 404;
}
See this document for more.