Syntax
- .htaccess files are case sensitive!
- file permissions are very important
- check /var/log/httpd/error.log if anything fails
Sample Configuration of Apache and .htaccess
/etc/httpd/conf/httpd.conf:
...
User nobody
Group nobody
...
AllowOverride AuthConfig
...
$ ls -la
total 4972
drwxr-xr-x 3 someuser root 4096 Sep 11 20:41 .
drwxr-xr-x 4 someuser nobody 4096 Sep 11 19:21 ..
-rw-r--r-- 1 someuser root 4430783 Sep 5 22:34 somefile
-rw-r--r-- 1 someuser root 119 Sep 11 17:17 .htaccess
drwxr-xr-x 2 someuser root 4096 Sep 11 19:05 somedir
$ htpasswd2 -c /home/someuser/.htpasswd someuser <- creates a new password file!
if you want to change an existing password file, omit '-c'
New password:
Re-type new password:
$ ls -la .htpasswd
-rw-r-r- 1 root root 19 Sep 11 16:22 .htpasswd
.htaccess:
AuthUserFile /home/someuser/.htpasswd
AuthGroupFile /dev/null
AuthName "private section"
AuthType Basic
#SSLRequireSSL
require user someuser