Is it possible to password protect a virtual directory (such as a wordpress category):
/c/sofas/
It looks like <Location /c/sofas/>
would work in httpd_config, but not .htaccess
Is it possible? Possibly with a mod_rewrite somewhere?
Is it possible to password protect a virtual directory (such as a wordpress category):
/c/sofas/
It looks like <Location /c/sofas/>
would work in httpd_config, but not .htaccess
Is it possible? Possibly with a mod_rewrite somewhere?
Unfortunately <Location>
directive isn't allowed in .htaccess
.
But there is an alternate neat solution using mod_setenvif
.
# set env variable SECURED if current URI is /c/sofas/
SetEnvIfNoCase Request_URI "^/c/sofas/" SECURED
# invoke basic auth is SECURED is set
AuthType Basic
AuthName "My Protected Area"
AuthUserFile /full/path/to/passwords
Require valid-user
Satisfy any
Order allow,deny
Allow from all
Deny from env=SECURED
allow,deny
reversed. Try it now. –
Clearwing /c/sofas/
URLs. –
Clearwing © 2022 - 2024 — McMap. All rights reserved.