IT Base of Knowledge’s Weblog

December 24, 2008

Add a password access to a directory of your website

Filed under: Linux — itbdc @ 12:09 pm

At first you need to create a file containing your password

htpasswd -c /var/www/itbdc/.htpasswd itbdc

Then create a file in your website: /var/www/itbdc/.htaccess

AuthType Basic
AuthUserFile /var/www/itbdc/.htpasswd
AuthGroupFile /dev/null
AuthName EnterPassword

require user itbdc
require valid-user

Then edit your httpd.conf and check those two lines:

AccessFileName .htaccess
<Directory>
	[...]
    AllowOverride All
	[...]
</Directory>

/etc/init.d/httpd restart

Blog at WordPress.com.