Royal Pinto
Royal Pinto

Reputation: 183

Password protect directory in Apache

I want to set password for one directory using Apache server so that only authorized persons can access to the directory. I have created .htpasswd file inside the directory. And it contains one line

username:$apr1$5H33Pfw6$WApVs3KlrU7QgBqYrFgeW.

password is "password". And my Directory Preferences are

<Directory />
AuthType Basic
AuthName "Example Repository"
AuthUserFile /.htpasswd
Require valid-user
</Directory>

When accessing the directory from browser it asks for username and password. After entering username and password request fails. Http Request error code is 403. What could be the error. Thanks.

Upvotes: 1

Views: 1130

Answers (2)

unNamed
unNamed

Reputation: 1019

Taken from http://httpd.apache.org/docs/2.2/mod/mod_authn_file.html

Syntax: AuthUserFile file-path

File-path is the path to the user file. If it is not absolute, it is treated as relative to the ServerRoot.

Upvotes: 1

geezmo
geezmo

Reputation: 161

You must provide the complete path to your .htpasswd file. Try with

AuthUserFile /complete/passwd/file/path/.htpasswd

Hope it helps.

Upvotes: 1

Related Questions