怎樣使用 htaccess 資料夾密碼保護?
1. Telnet 到閣下的 FTP 帳戶
telnet ftp.yourdomain.com
2. 建立一個密碼檔案 執行以下命令
htpasswd -c [檔案名稱] [用戶名稱]
例如: htpasswd -c .htpasswd testpro
3. 接著閣下需填上用戶密碼
如需增加新用戶,可執行以下命令
htpasswd [密碼檔案名稱] [用戶名稱]
例如: htpasswd .htpasswd testpro2
接著閣下需填上新用戶testpro2的密碼
AuthUserFile require valid-user
請把以下檔案放在 testprotect 資料夾內
require valid-user
閣下可透過伺服器的 htpasswd 建立密碼檔案
AuthGroupFile
AuthName
AuthType Basic
如閣下需要保護 public_html 資料夾內的 testprotect 資料夾
AuthUserFile 必需填寫絕對路徑
假設閣下的保護資料夾在 /home/wcpdemo/testprotect 及保護密碼檔案名為 .htpasswd
AuthUserFile /home/wcpdemo/public_html/testprotect/.htpasswd
AuthGroupFile /dev/null
AuthType Basic
AuthName Protected


