0

I've 2 domains e.g. foo.com and bar.com which share the same document root. The sites are protected by a .htaccess file

AuthUserFile ../.htpasswd
AuthName "No Access"
AuthType Basic
<Limit GET POST PUT>
    require valid-user
</Limit>

how can I set the AuthUserFile depending on the host?

pseudocode:

if (host == foo.com) {
    AuthUserFile ../.htpasswd_foo
} else {
    AuthUserFile ../.htpasswd_bar
}
AuthName "No Access"
AuthType Basic
<Limit GET POST PUT>
    require valid-user
</Limit>

If this is not possible are there any other ways to get different logins for the 2 domains?

mirsch
  • 168
  • 7

1 Answers1

-1

Try setting it up like this:

#site1.com
setenvIfNoCase Host site1\.com pass_1
AuthType Basic
AuthName "Site1.com Login Required"
AuthUserFile "/home/userdir/.htpasswds/site1.pwd"
Require valid-user
Order allow,deny
Allow from all
Deny from env=pass_1
Satisfy any

#site2.com
setenvIfNoCase Host site2\.com pass_2
AuthType Basic
AuthName "Site2.com Login Required"
AuthUserFile "/home/user_dir/.htpasswds/site2.pwd"
Require valid-user
Order allow,deny
Allow from all
Deny from env=pass_2
Satisfy any
Brandon Rohde
  • 298
  • 1
  • 3
  • 11
  • this doesn't work. it always uses the second part. I assume it completely overrides the first one. – mirsch Jul 25 '13 at 19:09