Hello.
I'm using nginx over a year now for my image sharing website and i had no problems until now.
The problem began to appear when my website reached 300,000+ images, which i keep in one directory.
After searching through forums I finally found out a solution to my problem - dividing and storing the files in different subdirectories, defined by the filenames of the images. Example: file 123456.jpg goes to /images/12/34/123456.jpg etc.
So far so good. But this kind of change requires tweaking and adjusting the php code itself to serve the images from the correct directories, which is the last thing i wanna mess around with. I was wondering if there is a way that function could be made by using nginx.
For example: server receives file request "/images/123456.jpg". Ok, but the file isn't there - it's in the /images/12/34/ subdirectory, so nginx takes the first two chars of the filename, then the 3rd and the 4th one and then checks if that file exists in this folder. This way a php correction won't be needed and things should be much faster than the other way. Another advantage is that links to the website's images across the internet won't broke after the change is made using nginx. Am i right?
Please, could someone try to write a function / if statement for this to work?
I will be most pleased.
Thanks in advance and excuse my english.