Currently I try to prevent access to a directory on my apache2 web-server via .htaccess
and basic authentication:
AuthType Basic
AuthName "Private"
AuthUserFile ?/.htpasswd
require valid-user
Lets say directory path is /foo/bar
, so .htacccess
as well as .htpasswd
are located under /foo/bar/.htaccess
and /foo/bar/.htpasswd
.
Absolute addressing from /foo/bar/.htpasswd
doesn't work. My user account has no permissions to access /
.
I already tried to address it relative from within the directory. But apache2 resolves relative addresses from the apache2 root directory, i.e. /etc/apache2/
.
Actually I only have access to edit content within /foo/bar
. I have no control over apache2, too.
Question: How to address the .htpasswd
file for AuthUserFile
under given limitations?
it cannot access the file simply means your full path to password file isn't correct.
It needs to be full system path i.e.
AuthType Basic
AuthName "Private"
AuthUserFile /home/jsmith/foo/bar/.htpasswd
require valid-user