简体   繁体   English

防止使用.htaccess直接访问文件

[英]Prevent direct access to files with .htaccess

Ok, I am using codeigniter and I have a secure login section. 好的,我正在使用codeigniter,并且有一个安全的登录部分。 Inside the login users are able to download files. 在登录内部,用户可以下载文件。

What I need to do is stop people been able to access the file directly. 我需要做的是阻止人们直接访问该文件。 I figure there will be a way using .htaccess to check for a authenticated variable that I could set in the POST array or something similar. 我认为将有一种使用.htaccess的方法来检查可以在POST数组或类似内容中设置的经过身份验证的变量。

Any pointers would be good, was a bit of a hard topic to google because I'm not really sure what the best way to do it is. 任何指针都将是很好的,对于Google来说这是一个很难的话题,因为我不太确定最好的方法是什么。

Thanks. 谢谢。

A good Google would be: php secure file download 一个好的Google将是:php安全文件下载

Some helpful results I found for you: 我为您找到了一些有用的结果:

To keep the files inside your webroot and password protect the directory they are inside of, and then use PHP to push the file(s) to the browser for download: http://www.nopersonal.info/aboutkateers/php_stuff/php_force_download.php 要将文件保留在您的Webroot中,并使用密码保护它们所在的目录,然后使用PHP将文件推送到浏览器以进行下载: http : //www.nopersonal.info/aboutkateers/php_stuff/php_force_download。 PHP

Or, if you have access to a directory above your web root: http://forums.tizag.com/showthread.php?t=893 或者,如果您有权访问Web根目录上方的目录: http : //forums.tizag.com/showthread.php?t=893

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM