Reputation: 87
We have files stored in a directory "uploads/downloads" which are accessed through a php file in the manner of https://www.example.com/request_file.php?file=123. That PHP file queries a database table and returns a file stored in the directory mentioned.
Using htaccess (I presume) how can I deny access to any files in the "uploads/downloads" directory unless the are being accessed through the request_file.php page?
Upvotes: 2
Views: 1130
Reputation: 57719
Try something like this:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !request_file.php
RewriteRule ^uploads/downloads/ - [L,R=404]
Upvotes: 2