woff 發表於 2010-4-12 12:39:53

.htaccess 密碼保護

本帖最後由 MrAJ 於 2009-9-24 11:13 編輯

有時在架設網站時,如果某一資料夾下的頁面不想給別人看到,可以使用.htaccess的保護方式幫忙。
在想要設密碼的資料夾下加入.htaccess 在寫上:

AuthName "MemberPage" ----> 瀏覽器出現的說明
AuthType Basic
AuthUserFile "C:/Apache/htdocs/testing/.htpasswd" ---->密碼檔案的路徑
require valid-user

另外除了.htaccess 之外還另外在新增一個檔案 .htpasswd。
但是 .htpasswd這隻檔案不能直接新增,因為此檔案密碼是要加密過的。
所以要利用apache內附的一隻htpasswd.exe (在Apache\bin資料夾下)檔案來建立。

利用文字模式下達指令

htpasswod -b -c .htpasswd root password

這樣就會在Apache\bin資料夾下產生一個.htpassword的檔案。
頁: [1]
查看完整版本: .htaccess 密碼保護