我想只提供对单个目录(/ dist)的公共访问。我有一个.htaccess文件,其中包含以下内容:
Order deny,allow
Deny from all
<Directory /dist>
Order Allow,Deny
Allow from all
</Directory>
我试图首先拒绝访问所有人,然后用/ dist目录的允许规则覆盖该指令。但是,当我尝试通过浏览器访问任何文件时,我得到以下内容:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at you@example.com to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
我做错了什么?
答案 0 :(得分:2)
正如@Anubhava所说,在htaccess contex中不允许使用目录,这个指令只能在目录上下文中使用。您可以使用RewriteRule拒绝访问除/ dist目录之外的所有内容:
RewriteEngine on
RewriteRule !dist - [F]
除了对/ dist。
的请求外,这将禁止所有的请求