apache - htaccess <目录> 拒绝所有

标签 apache .htaccess apache2

我最近一直在清理我的项目。我的根目录中有一个主 .htaccess 和其他 6 个。其中 5 个运行了 Options -Indexes ,我没有看到任何允许任何目录查看的点,因此将其移至主目录。所以现在我只有 2 个 .htaccess 文件。 main 和 /system 中的一个包含

# Block External Access
deny from all

所以我想仅在主程序中在 /system 上运行它。所以我删除了/system中的一个并添加了

 # Block External Access
<Directory "/system/">
deny from all
</Directory>

到我的主 .htaccess 文件留下 1!

但现在我得到了

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Apache/2.2.17 (Ubuntu) Server at 10.0.1.5 Port 80

目标是阻止读取/system 及其子目录中的任何文件,但允许从整个项目的一个 .htaccess 文件中查看所有其他内容。关于如何解决这个问题有什么想法吗?我进行了一些 Google 搜索,但没有真正找到任何结果。

最佳答案

您不能使用Directory directive在 .htaccess 中。但是,如果您在/system 目录中创建一个 .htaccess 文件并将以下内容放入其中,您将得到相同的结果

#place this in /system/.htaccess as you had before
deny from all

关于apache - htaccess <目录> 拒绝所有,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8683496/

相关文章:

php - 在 Apache/Windows 2008 上使用 PHP 和 Oracle 时身份验证登录页面无法正常工作

apache - 在 WAMP 中制作漂亮的永久链接

php - 删除 CI ubuntu 12.04 中的 index.php 文件

apache2 - 如何将jsession id添加到apache http访问日志中

WebSocket 握手期间的 Socket.io 代码 200 错误

java - "Content-Disposition header"中的配置 "Apache HTTP Server"

php - Apache、PHP、MySQL、PDO、权限被拒绝、laravel

apache - 如何使用 .htaccess 提供 gziped 字体? (没有 mod gzip 或 deflate)

regex - Htaccess RewriteRule 接受特殊字符

django - 如何在ubuntu上为django restful服务配置apache2