2017-05-17 42 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要求所有進來的請求。