允许从本地主机 .htaccess 列出目录

发布于 2024-09-25 19:12:48 字数 372 浏览 0 评论 0原文

我的本地网络服务器上有一个文件目录,我想让它只有本地用户才能查看目录列表。例如,如果朋友从他家访问该网站,他应该无法看到 site.com/files/,但可以获取文件 site.com/files/image.png。对于本地用户,我希望他们能够做到这两点。我尝试了以下代码,但它不起作用。有什么想法吗?

SetEnvIf REMOTE_ADDR 192.168.1.* local
<IfDefine local>
Options +Indexes
</IfDefine>
<IfDefine !local>
Options -Indexes
</IfDefine>
Allow from ALL
Deny from NONE

i have a files directory on my local web server and i want to make it so that only local users can view the directory list. for example if a friend visits the site from his house, he should not be able to see site.com/files/ but can get the file site.com/files/image.png. for local users i want them to be able to do both. i tried the following code but it does not work. any ideas?

SetEnvIf REMOTE_ADDR 192.168.1.* local
<IfDefine local>
Options +Indexes
</IfDefine>
<IfDefine !local>
Options -Indexes
</IfDefine>
Allow from ALL
Deny from NONE

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

久夏青 2024-10-02 19:12:48

使用以下内容创建 .htaccess 并将其放置在 /files/ 中。

order deny,allow
deny from all
allow from 192.168.1

Create .htaccess with the following and place it in /files/.

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