htaccess Redirect for folder to prevent direct access

Viewed 466

I have a folder in my project where the images sent by users are stored, which are private and are meant to be seen only by other users. I wish to redirect the page to some other page if someone attempt to open an image directly using the address bar (in case someone knows the where the images are stored) in the browser, also at the same time the images should load using img src="". My current htaccess file looks smth like this right now:

<IfModule mod_rewrite.c>
  Options -Multiviews
  RewriteEngine On
  RewriteBase /vector/frontend
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule  ^(.+)$ index.php?url=$1 [QSA,L]
</IfModule>

My code is in PHP. How can this be done?

0 Answers
Related