/ / Môže sa htpasswd vzťahovať na všetky adresy URL okrem jednej? - apache, .htaccess, .htpasswd

Môže sa htpasswd vzťahovať na všetky adresy URL okrem jedného? - apache, .htaccess, .htpasswd

Mám nastavenie htaccess pre svoju doménu, ale chcem, aby jedna konkrétna adresa URL nemala ochranu htpasswd. Táto URL je prepísaná URL a nemá k nej priradený skutočný adresár.

Existuje spôsob, ako použiť root htaccess na ochranu celého webu s výnimkou jednej konkrétnej adresy URL?

Upraviť (môj kód, vrátane návrhu Jon Lin, ktorý pre mňa nefunguje):

RewriteCond %{SERVER_NAME} =subdomain.example.com
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
SetEnvIf Request_URI "^/messenger/parse" NOPASSWD=true
AuthUserFile /xxx/xxx/xxx/xxxxxx/subdomain.example.com/.htpasswd
AuthName "Staging Server"
AuthType Basic
Order Deny,Allow
Satisfy any
Deny from all
Require valid-user
Allow from env=NOPASSWD

odpovede:

3 pre odpoveď č. 1

Môžete nastaviť niečo podobné SetEnvIf nastaviť premennú prostredia pre daný URI požiadavky. Potom v definícii autor môžete použiť Satisfy Any a Allow from env direktívy na informovanie apache, že prístup môže byť udelený buď autentifikáciou, alebo ak existuje premenná prostredia (ktorá je nastavená iba pre konkrétny URI). Príklad:

# set the NOPASSWD variable if the request is for a specific URI
SetEnvIf Request_URI "^/specific/uri/nopasswd/$" NOPASSWD=true

# Auth directives
AuthUserFile /var/www/htpasswd
AuthName "Password Protected"
AuthType Basic
Order Deny,Allow
# Any requirment satisfies
Satisfy any
# Deny all requests
Deny from all
# except if user is authenticated
Require valid-user
# or if NOPASSWD is set
Allow from env=NOPASSWD