要求基于URL的用户?

当URL是/foo/user1/* ,我想要求用户user1当URL是/foo/user1/* user2 /foo/user1/* ,用户user2等。是否可以这样做?

例如,我想要做这样的事情:

 AliasMatch ^/foo/([^/]+)(/.*)? /home/$1/foo$2 <LocationMatch "^/foo/([^/]+)(/.*)?"> SSLRequireSSL AuthType Basic AuthName "foo" AuthUserFile /etc/apache2/htpasswd Require user $1 </LocationMatch> 

假设/home/user1/fooX中的文件属于user1您可以考虑使用mod_authz_owner并使用Require file-owner

 <Directory /home/*/public_html> AuthType Basic AuthName "User files" AuthUserFile /etc/apache2/htpasswd Satisfy All Require file-owner </Directory>