zencart通過密碼保護網站文件、目錄,限制
下面提到的 AuthUserFile /home/path/.htpasswd ,用于指定密碼文件.htpasswd, 該文件需要手工建立。 宇塵網絡幫助中心域名知識|虛擬主機知識|VPS主機知識|服務器知識|網站建設知識|網絡推廣
/home/path 是用于存放 .htpasswd 文件的目錄,相應修改。
Google下能找到很多相關說明,也可以在線生成 .htpasswd 密碼文件,例如:
這些代碼需要保存到 .htaccess 文件,并置于需要保護的目錄下,例如zencart網店的admin目錄下。
基本的密碼保護方法:
代碼: 全選
# basic password protection
<IfModule mod_auth.c>
AuthUserFile /home/path/.htpasswd
AuthName “Username and password required”
AuthType Basic
<Limit GET POST>
Require valid-user
</Limit>
</IfModule>
僅某些IP可以訪問,其它的需要輸入密碼:
代碼: 全選
# password protect excluding specific ips
<IfModule mod_auth.c>
AuthName “Username and password required”
AuthUserFile /home/path/.htpasswd
AuthType Basic
Require valid-user
Order Deny,Allow
Deny from all
Allow from localhost
Allow from 111.222.333.444
Allow from 555.666.777.888
Satisfy Any
</IfModule>
僅某些IP段的用戶訪問需要密碼,其它IP的用戶無需密碼:
代碼: 全選
# password protect only for specified ips
<IfModule mod_auth.c>
AuthName “Username and password required”
AuthUserFile /home/path/.htpasswd
AuthType Basic
Require valid-user
Order Allow,Deny
Allow from all
Deny from 111.222.333.444
Deny from 555.666.777.888
Satisfy Any
</IfModule>
密碼保護單個文件:
代碼: 全選
# password protect single file
<IfModule mod_auth.c>
<Files “protected.html”>
AuthName “Username and password required”
AuthUserFile /home/path/.htpasswd
Require valid-user
AuthType Basic
</Files>
</IfModule>
其中 protected.html 是需要輸入密碼才能訪問的文件。
密碼保護多個文件:
代碼: 全選
# password protect mulitple files
<IfModule mod_auth.c>
<FilesMatch “(protected.html)|(passwords.txt)”>
AuthName “Username and password required”
AuthUserFile /home/path/.htpasswd
Require valid-user
AuthType Basic
</FilesMatch>
</IfModule>
上面指定 “protected.html” 和 “passwords.txt” 文件需要密碼才能打開。同樣可以加上更多的文件。 仿牌空間、香港月付空間、韓國月付空間、日本月付空間、荷蘭VPS、香港VPS
密碼保護多種文件類型:
代碼: 全選
# password protect mulitple file types
<IfModule mod_auth.c>
<FilesMatch “.(inc|txt|log|dat|zip|rar)$”>
AuthName “Username and password required”
AuthUserFile /home/path/.htpasswd
Require valid-user
AuthType Basic
</FilesMatch>
</IfModule>
這樣就密碼保護了這些類型的文件:.inc, .txt, .log, .dat, .zip, .rar。
密碼保護除了某個文件外的所有文件:
代碼: 全選
# password protect everything except a single file
<IfModule mod_auth.c>
AuthName “Username and password required”
AuthUserFile /home/path/.htpasswd
Require valid-user
AuthType Basic
<Files “open-access.html”>
Order Deny,Allow
Deny from all
Allow from 123.456.789
Satisfy any
</Files>
</IfModule>
這樣就只有訪問 open-access.html 這個文件不需要密碼,該文件可以是保存在某個子目錄中。 美國月付空間、月付美國空間、美國VPS、美國服務器租用
密碼保護除了某些文件外的所有文件:
代碼: 全選
# password protect everything except specified files
<IfModule mod_auth.c>
AuthName “Username and password required”
AuthUserFile /home/path/.htpasswd
Require valid-user
AuthType Basic
<FilesMatch “(open-access-1.html)|(open-access-2.html)|(open-access-3.html)”>
Order Deny,Allow
Deny from all
Allow from 123.456.789
Satisfy any
</FilesMatch>
</IfModu
更多技術知識,更多網絡服務,盡在宇塵網絡。我們的成長,離不開你們的支持,宇塵網絡,歡迎您的訪問。