Simple arithmetics in nginx config

mennanov nginx-forum at
Mon Nov 28 08:11:46 UTC 2011

Hello! I have an image folder called "i" in site's root folder, it has
many subfolders like 0, 100, 200, 300 ... 600000, etc..
So in folder "200" there are images from 200.jpg to 299.jpg, in folder
"300" there are 300.jpg to 399.jpg ans so on. As you can see i create a
new folder for every 100th image because i don't want to have all the
images in one folder (there are too much).

The problem is that i can't calculate a proper folder name, i tried like

location ~ /i/(.*)\.jpg {
	    set $folder $1-($1%100);
	    try_files /i/$folder/$1.jpg =400;

but of course it does not work due to syntax error.

Help me please

Posted at Nginx Forum:,219172,219172#msg-219172

More information about the nginx mailing list