【问题标题】:Apache: How do I open up read access to a directory & its contents, giving a directory listing, but not write access?Apache:如何打开对目录及其内容的读取访问权限,提供目录列表,但不提供写入访问权限?
【发布时间】:2020-05-21 05:03:34
【问题描述】:

大约二十年前,我做过这个,但现在我似乎无法弄清楚。我认为 Apache 需要一个指令 - 最好在 <Directory> 容器中 - 否则它认为打开文件权限是一个配置错误,但我今天不知道该怎么做。

为了澄清,我想要做的是指向一个没有 html 文件的目录的链接,让用户浏览那里的文件并下载“读取”,但没有写入权限。如果它在那个目录中,任何人都可以读取它,只是没有新文件,也没有对现有文件的更改。

【问题讨论】:

  • 对于投票“关闭”的人,很多人都在问如何加强安全性,所以问如何重新打开它不应该是不合时宜的!而且,现在也有了答案。

标签: apache directory read-access


【解决方案1】:

第二天早上更清楚地想到咖啡,我意识到可以在 httpd.conf 中找到一个很大的帮助,果然那里有一个关于这个的评论,它指向 this in the docs.

然后我意识到需要为“索引”目录添加一个例外,描述为:

> Indexes
>     If a URL which maps to a directory is requested and there is no DirectoryIndex (e.g., index.html) in that directory, then
> mod_autoindex will return a formatted listing of the directory.

所以……

我试过了:

<Directory "/the/dir">
   Options Indexes
</Directory>

然后$ apachectl graceful

然后又试了一次,成功了!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-21
    • 2011-05-22
    • 2018-11-12
    • 1970-01-01
    相关资源
    最近更新 更多