2017-04-20 106 views
1

我想用密碼保護完整的/ var/www/html/*區域,但排除一個文件。 我想這個代碼:.htaccess文件沒有工作。

<Files *.*> 
AuthType Basic 
AuthName "Service-Login" 
AuthUserFile /path/tomypasswdfile/... 
Require valid-user 
</Files> 

<Files /index.alternetive.php> 
#Order allow,deny 
Require all granted 
#Allow from All 
#Allow from env=allow 
#Satisfy any 

</Files> 

的登錄工作正常,但所有文件,包括「index.alternetive.php」 - 文件。

我的apache2在Ubuntu-Xenial上運行。

非常感謝

回答

0

文件名是您的問題。將其更改爲類似index_alternetive.php的內容,並且適用於您。

1

Files不適用於路徑名稱,但僅適用於文件名。如果你想要一個特定的路徑,你必須把它放在一個Directory指令中,或者放在它所屬的.htaccess中。在你的情況下,這似乎是根目錄

AuthType Basic 
AuthName "Service-Login" 
AuthUserFile /path/tomypasswdfile/... 
Require valid-user 

<Files index.alternetive.php> 
Require all granted 
</Files> 

也看看拼寫,例如, alternetive vs alternative