除非访问特定的php页面,否则拒绝访问目录中的所有文件 [英] Deny access to all files in a directory unless a specific php page is referrer
本文介绍了除非访问特定的php页面,否则拒绝访问目录中的所有文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们将文件存储在目录上载/下载中,这些文件可以通过php文件以 https://www.example.com/request_file.php?file=123 。该PHP文件查询数据库表并返回存储在上述目录中的文件。
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.
使用htaccess(我认为)如何拒绝访问上载中的任何文件/ downloads目录,除非通过request_file.php页面访问该目录?
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?
推荐答案
尝试如下操作:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !request_file.php
RewriteRule ^uploads/downloads/ - [L,R=404]
这篇关于除非访问特定的php页面,否则拒绝访问目录中的所有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文