2017-03-22 92 views
1

當訪問專門命名的文件我有我的htaccess允許使用htaccess的密碼

AuthType Basic 
AuthName "dev" 
AuthUserFile "/home/example/.htpasswds/public_html/example/passwd" 
Require valid-user 

我想允許訪問某些文件,而無需輸入密碼以下。 這些文件被命名爲任何類似

http://example.com/56B2BB34645F8763C7DC8ADEDC34A0BD.txt 
http://example.com/94B2AC8513F8791C7DC8AABFE3DDA0AC.txt 

,並在名稱中包含

"Comodo DCV" 

我試圖

AuthType Basic 
AuthName "dev" 
AuthUserFile "/home/example/.htpasswds/public_html/example/passwd" 
<RequireAny> 
    <RequireAll> 
    # example to allow access to callbacks directory 
    #Require expr %{REQUEST_URI} =~ m#^/callbacks/.*# 
    Require expr %{REQUEST_URI} =~ m#^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
</RequireAll> 
Require valid-user 
</RequireAny> 

,但我只是得到一個500錯誤的任何txt文件,當我嘗試查看一個txt文件。

我在哪裏出錯了?

回答

1

您可以使用這些指令,允許對某些申請與AUTH呈現:

SetEnvIfNoCase Request_URI "^/[A-F0-9]{32}\.txt$|Comodo\ DCV" ALLOWED=TRUE 

AuthType Basic 
AuthName "dev" 
AuthUserFile /home/example/.htpasswds/public_html/example/passwd 
Require valid-user 
Order deny,allow 
deny from all 
allow from env=ALLOWED 
Satisfy any