仅对脚本进行读/写

发布于 2024-09-24 09:25:12 字数 172 浏览 0 评论 0原文

似乎是关于 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

黑凤梨 2024-10-01 09:25:12

阻止访问非脚本的最简单方法:将其移至 Web 服务器的文档根目录之外。如果您的 PHP 文件由 /var/www/htdocs 提供,请将数据文件放入 /var/www/data 中。

如果不可能,.htaccess 解决方案如下所示:

# don't let anyone access these files directly
Order allow,deny
Deny from all

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:

# don't let anyone access these files directly
Order allow,deny
Deny from all
寒尘 2024-10-01 09:25:12

您可以将目录的所有权更改为 wwwapache 用户,具体取决于您的 Web 服务器运行的用户。

然后确保该目录的权限设置为644,以便只有所有者可以写入。如果你不希望其他人能够阅读,就将其设置为 600 即可。

You can change the ownership of the directory to the www or apache 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文