簡體   English   中英

什么是apht htaccess配置,要求對所有這些URL進行身份驗證?

[英]What is apache htaccess configuration to require authentication for all except for these URLs?

我需要什么htaccess行/配置來確保站點的所有部分(文件和URL)都受到身份驗證的保護,但對於給定的有限URL集除外。 例如,如果可以的話,除“ /api/.*”外的所有內容。

實際的身份驗證可能類似於以下內容,但這是我將其包裝在指令中的方式...

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

謝謝

您可以使用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>

這似乎可行:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM