Forum Moderators: phranque
There are thousands of thumbnails on my webserver and I'd like do group them by category id in seperate directories and use mod_rewrite to direct the request to the right file in the right directory. for example /thumbs/62_1_picname.jpg should translate to /thumbs/7/1.jpg because category 62 is in a directory named 7 (Let say I want to group every 10 categories together).
Is it possible to do that with mod_rewrite? Basically I need to make some calculations on the category value.
If it's not possible, what's the best approach I should take? I just don't want to dump so many files in one directory because of performance issues and maybe even hosting limitations
Thank you
And last, why not making these directories, not based on category, but the actual filename? I mean this:
asdsd.jpg -> /a/s/asdsd.jpg
asj2d.jpg -> /a/s/asj2d.jpg
awewe.jpg -> /a/w/awewe.jpg
reqre.jpg -> /r/e/reqre.jpg
This one is perfectly possible with mod_rewrite without any external file, or any 'complicated' rewriting solutions.
Doing that requires only a simple re-arrangement of the URL text, with no calculation needed, and is a 'standard' method used on sites with lots of files that 'appear' to reside in one URL-directory.
Note that what I've shown is just an example -- You can re-arrange the URL in any way you like to form the filepath, dropping parts of the URL-text, adding extra fixed text, etc.
Jim