htpasswdコマンドの使い方

ベーシック認証のかけ方をいつも忘れるのでメモ。

htpasswd -c -b /home/www/.htpasswd [username] [password]

.htaccessに次のように記載。

$ cd /home/www/docroot/hiddendir/
$ vi .htaccess
AuthUserFile /home/www/.htpasswd
AuthGroupFile /dev/null
AuthName "Basic Auth"
AuthType Basic
Require valid-user