mod_rewrite and .htaccess with catalogs

I have a catalog /images and this path is used in a script. I need to redirect script to search files in inner catalogs - /images1
/images2 etc. I have such .htaccess but it doesnt work. Help.

RewriteEngine On
RewriteOptions Inherit
RewriteBase /

RewriteCond %{REQUEST_URI} !^images/ [S=5] 
# skip next 5 rules (number of lines following, i.e. 2*NDIR+1, where NDIR is number of imgdirs)

RewriteCond %{REQUEST_URI} ^images/(.*)$
RewriteCond imgdir1/%1 !-f [S=1]
RewriteRule .* imgdir1/%1 [L]
RewriteCond imgdir2/%1 !-f [S=1]
RewriteRule .* imgdir2/%1 [L]
#...

instead of /images in html script should search files in
/images/images1/neededfile.jpg or if not found search in /images/images2/neededfile.jpg … and so on while not found or till next folder exist

Oh, I see your point now.

No, I dont know the answer to this, though I’d like to see it.

There may be someone else in this forum who can help you, otherwise your best option would be to have this question moved to the more specialized “server” forum. Ask one of the modertors.

Might help clear things up if you showed one or two examples of what you mean exactly.

/images/myimage1.jpg should go … ?