2017-07-07 109 views
1

我有一個apache 2.4服務器託管2個應用程序。其中一個可以免費訪問互聯網,另一個僅限於某些IP。所以我/etc/apache2.conf文件中,我有以下:限制訪問apache 2.4目錄,但允許某些文件

<Directory /var/www/> 
    Options FollowSymLinks 
    AllowOverride None 
    Require all granted 
</Directory> 

<Directory /var/other/> 
    Options FollowSymLinks 
    AllowOverride None 
    Require ip [ip] 
</Directory> 

這工作得很好,我得到一個禁止403試圖訪問任何網頁在/ var /其他被服務時,除非在右側IP IM 。不過,我現在想在沒有IP限制的情況下使/ var/other /目錄中的某些頁面可以自由訪問。我嘗試過各種組合,例如下面的嵌套<文件>標記,以授予對特定文件的所有訪問權限,但似乎無效。

<Directory /var/www/> 
    Options FollowSymLinks 
    AllowOverride None 
    Require all granted 
</Directory> 

<Directory /var/other/> 
    Options FollowSymLinks 
    AllowOverride None 
    Require ip [ip] 
    <Files "/var/other/page.php"> 
     Require all granted 
    </Files> 
</Directory> 

伊夫試圖把<文件>標籤中的「需要IP [IP]」前以及前後<目錄>標籤後,也似乎沒有工作。有誰知道這是否可行,以及我會如何去實施它?

回答

1

你不應該有目錄,不僅是文件名,在文件部分:

<Files "page.php"> 
相關問題