I have the following rewrite rules
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -s
RewriteRule ^wp-content/uploads/(.*)$ dl-file.php?file=$1 [QSA,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Where every request to the wp-content/uploads its handled by dl-file.php in order to check if user its logged in.
I need to still have that functionality but grant free access to images (png|jpg|gif|jpeg)
Im a bit lost i dont know how to modify the rewrite rule to check any file that its no an image.
before the rule that rewrites to dl-file.php you could insert more specific rules for images:
Each of the three rules has the same structure, I’ll explain the first one:
match anything in uploads that ends in .png
with the brackets you save the whole path into a variable $1.
the right hand side of the rule gives this variable, so if you look
at one specific url this boils down to:
the L at the end tells the rewrite engine that this is the last rule to apply.
so if it matches, the rewriting process ends here, your png-image is served.