Alex Sergeyev Wrote:
-------------------------------------------------------
> You can also build recursive redirects like in my
> example, without break
> to make nginx repeat cycle of rewrites again, up
> to 10 times.
Thanks a lot, Alex,
Your comments enlightened my path!
Here is the working configuration:
[code]
location ~ ^/(.*)/([^/]+)/image/([^/]*)$ {
set $part1 $1;
set $part2 $2;
set $filename $3;
rewrite ^.*$ /${part1}_$part2/image/$filename last;
}
location ~ ^/([^/]+)/image/([^/]*)$ {
set $folder $1;
set $filename $2;
rewrite ^.*$ /image/$folder/$filename break;
}
[/code]
The first location directive is recursive, and keeps joining the paths, replacing "/" by "_" on each iteration.
The second location directive is the final one. When all path pieces are already joined, it does the final rewrite.
Cool!
Anyway, a "string replace" function for the rewrite module remains a wish as a [i]feature request[/i]...
Thanks!