2010-02-16 5 views
0

내 사이트 (파일 & 개 URL)의 모든 부분이 특정 제한된 URL을 제외하고 인증에 의해 보호되도록하기 위해 필요한 htaccess lines/config는 무엇입니까? 예를 들어, "/api/.*"를 제외한 모든 것이 의미가있는 경우.이러한 URL을 제외하고 모두 인증을 요구하는 apache htaccess 구성은 무엇입니까?

실제적으로 인증은 아래와 같이 할 수 있지만 내가 지침이 포장 방법은 ...

AuthName "Dialog prompt" AuthType 
Basic AuthUserFile 
/home/site/.htpasswd Require 
valid-user 

감사

답변

1

작동하는 것으로 보입니다.

AuthUserFile /home/.htpasswd 
AuthName "Password Protected" 
authtype Basic 
Order Deny,Allow 
Satisfy any 
SetEnvIf request_uri "/api/" allow_all 
Deny from all 
Require valid-user 
Allow from env=allow_all 
+0

여러 개의 URL을 허용하려면 추가로 "SetEnvIf request_uri"/ blah/"allow_all" – bjohnb

1

당신은 사용할 수 SetEnvIf<IfDefine> :

SetEnvIf Request_URI ^/api/ no_auth_req 
# If no_auth_req is NOT defined then require authentication 
<IfDefine !no_auth_req> 
    AuthName "Dialog prompt" 
    AuthType Basic 
    AuthUserFile /home/site/.htpasswd 
    Require valid-user 
</IfDefine> 
+0

감사합니다. 하나 이상의 URL이 있는지 궁금한 점이 있습니까? 구문에 대해 어떻게 보이는지 보호하고 싶지 않습니다. – Greg

+0

@Greg : 정규식 패턴을 조정하거나 다른 SetEnvIf 지시문을 사용하십시오. – Gumbo

+0

실제로이 작업을 수행 할 수 없으며 같은 것을 말하는 사람에게 링크가 표시됩니까? http://perplexed.co.uk/543_apache_setenvif_cant_pass_variables_to_ifdefine.htm – Greg

관련 문제