Your .htaccess file is probably the problem. Here is the code I use creating new virtual domains with a /private passwd protected area:
my $HTPASSWD_BIN = '/usr/bin/htpasswd';
# add .htaccess and .htpasswd files
print "Writing .htaccess and .htpasswd files.....\n";
my $htpasswd_file = "$WWW_ROOT/$domain/.htpasswd";
my $htaccess = get_htaccess( $domain, $htpasswd_file );
print "$htaccess\n" if $VERBOSE;
write_file( "$WWW_ROOT/$domain/public_html/private/.htaccess", $htacce
+ss );
print `$HTPASSWD_BIN -b -c $htpasswd_file $domain $password`;
print "Done!\n";
sub get_htaccess {
my ($domain, $htpasswd ) = @_;
return <<CODE;
AuthUserFile $htpasswd
AuthGroupFile /dev/null
AuthName $domain
AuthType Basic
<Limit GET POST>
require valid-user
CODE
}
The first thing to do is put a .htaccess file in the format shown above into any browsable dir. Don't worry about passwords yet (set AuthUserFile to /dev/null or to an existing file whatever). Now if you browse to that dir you should get prompted for a username/pass. If not check the perms on the .htaccess file - can user apache/nobody read it. If you don't get the prompt the underlying issue is in httpd.conf. Find this:
#
# This controls which options the .htaccess files in directories can
# override. Can also be "All", or any combination of "Options", "FileI
+nfo",
# "AuthConfig", and "Limit"
#
AllowOverride None
Change the 'None' to 'All' to get .htaccess working then RTFM to see if you really want 'All' or would prefer 'Some but not all :-)'
Once you have the prompt the rest is details ie apache needs to be able to find and read the password file. As an aside you can send links that autologin in the form:
http://username:password@somedomain.com/private/
This is the same functionality that has been used to spoof bank domain names used for its original purpose.
|