Hi folks.
I've been assigned to create some new rewrite rules for our static-content servers (due to a change in our file system). This structure is based on the id of the elements, if I want to get an element with id 484792 the url would be:
[b]http://content.domain.com/v/484792[/b]
now, I'm trying nginx to serve the file from the path:
[b]/nfs/video/000/004/847/92/484792[/b]
more examples:
http://content.domain.com/v/3 -> /nfs/video/000/000/000/03/3
http://content.domain.com/v/123456789 -> /nfs/video/001/234/567/89/123456789
The problem is I can't figure out how to dynamically assign zero's to the left according to the length of the id. I've trying to use a recursive rule, but I'm concerned about the toll it takes on performance, as it's the only way I've found to append the zero's...
location ~ "/v/.+" {
root /path/to/nfs;
rewrite "^/v/(\d{3})(\d{3})(\d{3})(\d{2})(\d*)" /$1/$2/$3/$4/$5 last;
rewrite "^/v/(\d*)" /v/0$1 last;
expires max;
}
Is there any way to manage rules like this I might be missing?
Your advice would be much appreciated, thanks in advance.
Waldemar