大网数据广告活动
服务器运维问答

How do I properly deny access to a specific file with Apache 2.4?

· 52CE 我爱测

I am runninng Apache 2.4 on Windows 10. To deny access to DLL files in a specific directory, I try <Directory "${SRVROOT}/htdocs"> #... <Files "*.dll"> Require all denied </Files> #... </Directory> Without this, and given a nonex…

问题原文

原帖链接 · Johann Oskarsson · CC BY-SA 4.0

I am runninng Apache 2.4 on Windows 10. To deny access to DLL files in a specific directory, I try

<Directory "${SRVROOT}/htdocs">
#...
    <Files "*.dll">
        Require all denied
    </Files>
#...
</Directory>

Without this, and given a nonexistant file, such as foo.dll it gives 404. With the configuration, the same nonexistant foo.dll gives 403, so I know the configuration is valid; however, when I try to access bar.dll which exists in the given directory, I'm asked to download it. Why is that?

How do I figure out what might be overwriting my <Files ...> directive?

已采纳解答

原帖链接 · Johann Oskarsson · CC BY-SA 4.0

Ok, to achieve what I wanted, I revoked all access in the general case, and explicitly allowed individual files, like this.

<Directory "${SRVROOT}/htdocs">
    #...
    Require all denied

    <Files "*.exe">
        Options +ExecCGI
        SetHandler fcgid-script
        Require all granted
    </Files>

</Directory>

That properly prevents loading of .dll files and everything else extraneous in the directory.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-08-25)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。