I need to password protect many pretty URLs in .htaccess
via .htpasswd
. But I want different user/login for each of the many protected pretty URLs (and a general login for pages not specifically protected).
So, for example, I'd like to protect:
With a specific user/password:
http://www.example.com/pretty/url
With another user/password:
http://www.example.com/pretty/link
With a generic user/password (all of the others)
http://www.example.com/pretty/generic
http://www.example.com/pretty/all
http://www.example.com/pretty/
I was trying to use the code from this answer, which I found the most fitting to my needs:
# Do the regex check against the URI here, if match, set the "require_auth" var
SetEnvIf Request_URI ^/pretty/url require_auth=true
# Auth stuff
AuthUserFile /var/www/htpasswd
AuthName "Password Protected"
AuthType Basic
# Setup a deny/allow
Order Deny,Allow
# Deny from everyone
Deny from all
# except if either of these are satisfied
Satisfy any
# 1. a valid authenticated user
Require valid-user
# or 2. the "require_auth" var is NOT set
Allow from env=!require_auth
It works very well with a single pretty URL. But I wasn't able to find a way to adapt this to many URLs each of them with a different user via htpasswd
.