2017-05-17 34 views
1

我只想提供公共访问单个目录(/ dist)。我有以下内容的.htaccess文件:使用.htaccess授予访问权限到一个目录

Order deny,allow 
Deny from all 

<Directory /dist> 
    Order Allow,Deny 
    Allow from all 
</Directory> 

我想先拒绝访问所有,然后overwirte用的/ 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 [email protected] 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. 

我在做什么错?

+1

“目录”指令不允许在.htaccess中 – anubhava

回答

1

正如@Anubhava所说,在htaccess contex中不允许使用Directory dirctive,这个指令只能在Directory环境下使用。你可以使用一个重写规则,以拒绝所有除/ dist目录访问:

RewriteEngine on 

RewriteRule !dist - [F] 

这将禁止除/ DIST要求所有进来的请求。