I was wondering if it is possible to have nginx rewrite a URL to point to the most recent (last naturally sorted) version of a file? Basically, I have a directory full of revisions of a file, like this:
/var/files/file-5.6.10.3.txt
/var/files/file-5.6.10.12.txt
/var/files/file-5.6.10.20.txt
/var/files/file-5.6.12.1.txt
...
And I would like to rewrite a request for "file.txt" to the most recent version of that file. This is kind of what I want to do:
root /var/files;
rewrite file.txt $(ls -v /var/files | tail -1);
Or a 302 would be good too!
location file.txt {
return 302 $(ls -v /var/files | tail -1);
}
Please also note that symlinking is not an option :( I would like to have this handled by nginx, or some extension to nginx.
0 Answers