Saturday, April 28, 2012

Apache HTTP Server Authentication Access Control

修改 httpd.conf 設定檔,允許 AllowOverride AuthConfig 選項。

於欲限制存取目錄的 .htaccess 檔案新增以下內容。
AuthType Basic
AuthName "Restricted Files"
AuthUserFile /home/doe/public_html/.htpasswd
Require valid-user

新增使用者 jsmith 至已存在的 /home/doe/public_html/.htpasswd 密碼檔:
$ htpasswd /home/doe/public_html/.htpasswd jsmith

若密碼檔不存在,產生新密碼檔(-c 參數) 且新增使用者 jane:
$ htpasswd -c /home/doe/public_html/.htpasswd jane

參考資料



No comments:

Post a Comment