Hi!
In my .htaccess file I want to achieve the following.

1. If the picture file exists (e.g. dir1/pic.jpg or png or gif), it should be delivered without any rewrite.
2. If it does not exists (e.g. dir2/pic2.jpg or png or gif), it should be rewritten to /pics/pic2.jpg or png or gif.
3. If the file then doesn'T even exists in /pictures, rewrite shouldn't do anything more but just indicate as usual to the browser, that the file doesn't exists.

4. If the file doesn't end with .jpg .png or .gif at all, then the next rewrite-rule (for all other file types) should be followed.

Right now I tried for example all the outcommented things, but got always an 500 error:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^/(.*\.(png|gif|jpg)) /pics/$1 [L,NS,NC]
#RewriteRule ^/(.*\.(png|gif|jpg|jpeg)) /pics%{REQUEST_URI} [L,NS,NC]
#RewriteRule ^/(.*\.(png|gif|jpg)) /pics/$1 [NC]
#RewriteRule ^/(.*\.(png|gif|jpg|jpeg)) /pics%{REQUEST_URI} [NC]
#RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ /main.php

Sigh. Does anyone spot the mistake?

Greetings
DH2006