i had codeigniter project that contain the image folder and i want to make it unreachable from direct url access suppose some one enter url
http://localhost/project/images/Pricelistupdated.pdf
then it will be directly open in browser tab without login so i want to make it disable . when user login and click on download link only that time file will be download and open in new tab . either it can not open when anyone enter direct url in browser i used following
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(www\.)?projects/project/ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?projects/project/.*$ [NC]
RewriteRule \.(pdf|PDF|jpg|png|gif|PNG)$ - [F]
but this code also disable the download and open in new tab functionality
You should follow this link How to restrict access to files in a folder in codeigniter
As post described, you need to deny all direct access to your files and read it through controller while user is logged in using authentication.