With the settings below, both user-1
and user-2
can access to site-1
and site-2
after login. However, I want to change access rights as listed below:
user-1
can access only site-1
( http://test.local/site-1
) user-2
can access only site-2
( http://test.local/site-2
) How can I do it?
Site structure
test
site-1
index.php
site-2
index.php
index.php
.htaccess
.htpasswd
.htaccess
AuthType Basic
AuthName "Protected Test Site"
AuthUserFile /var/www/html/local/test/.htpasswd
Require valid-user
.htpasswd
user-1:$apr1$CraA.0n7$JRqS7GyggMKNYcTP65rAW/
user-2:$apr1$NbKoZeyJ$P33C/1ceg1XGfLaPsWBgW1
test.local.conf
<VirtualHost *:80>
ServerName test.local
DocumentRoot /var/www/html/local/test
<Directory /var/www/html/local/test>
AllowOverride AuthConfig
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Either change:
Require valid-user
to:
Require user user-1
alternatively create yourself two group files, and change the line to something along the following lines:
Require group siteOneUsers
Along with what I did above in OP, I solved the problem with creating additional .htaccess files right inside site-1
and site-2
so the contents are:
site-1/.htaccess
AuthUserFile /var/www/html/local/test/.htpasswd
Require user user-1
site-2/.htaccess
AuthUserFile /var/www/html/local/test/.htpasswd
Require user user-2
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.