仅对脚本进行读/写
似乎是关于 .htaccess
的问题,不确定我应该使用什么。
如何使 /data/
文件夹中的文件仅供脚本读取
和写入
?
用户不应该可以从浏览器窗口访问它们。
Seems it is a question about .htaccess
, not sure what should I use.
How can I make files inside /data/
folder available to read
and write
only for scripts?
Users should not have access to them from browser window.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
阻止访问非脚本的最简单方法:将其移至 Web 服务器的文档根目录之外。如果您的 PHP 文件由
/var/www/htdocs
提供,请将数据文件放入/var/www/data
中。如果不可能,
.htaccess
解决方案如下所示:Simplest way to block access to non-scripts: move it outside the web server's document root. If your PHP files are served from
/var/www/htdocs
, put your data files in/var/www/data
.If that's not possible, the
.htaccess
solution looks like:您可以将目录的所有权更改为
www
或apache
用户,具体取决于您的 Web 服务器运行的用户。然后确保该目录的权限设置为644,以便只有所有者可以写入。如果你不希望其他人能够阅读,就将其设置为 600 即可。
You can change the ownership of the directory to the
www
orapache
user, depending on what user your web-server is running as.Then make sure that the permissions of the directory are set to 644 so that only the owner can write. If you want nobody else to be able to read, just make it 600.