- 假設你要為你後台的登入系統加上一層保護,可以考慮設定 Apache 密碼。
- 修改httpd.conf
[shell]vim /etc/httpd/conf/httpd.conf
[tell]找到303行及318行。[/tell]
[com]303行:設定根目錄的存取權限。[/com]
[com]318行:設定Document Root 存取權限[/com]
[vim]AllowOverride all
[com] AllowOverride:允許被子目錄下的.htaccess 覆蓋。[/com]
[shell]cd /var/www/html/your_site
[shell]vim .htaccess
[vim]<files login.php>
AuthName "Protect login by .htaccess"
Authtype Basic
AuthUserFile /var/www/apache.passwd
require valid-user
</files>
[shell]htpasswd -c /var/www/apache.passwd test
[Print]New password: [com]輸入 user 密碼[/com]
Re-type new password: [com]再輸入一次[/com]
Adding password for user test[/Print] [com]新增使用者 test 成功[/com]
[shell]cat /var/www/apache.passwd
test:1ERgdw/..iS4yo [com] user 的密碼(已編碼)[/com]