我的问题
为什么 .htaccess 和 .htpasswd 不接受我的登录信息?
我的资源来了解我应该做什么
- http://www.addedbytes.com/blog/code/password-protect-a-directory-with-htaccess/
- http://www.elated.com/articles/password-protecting-your-pages-with-htaccess/
我做了什么?
我从phpinfo()
我的根目录的完整路径:/home/userid/public_html
我将 .htpasswd 放入根文件夹 (public_html) 中,因此我的 .htpasswd 的完整路径:/home/userid/public_html/.htpasswd
我想通过密码保护的管理文件夹名称:adminfolder
我把我的adminfolder
放入根文件夹(public_html)
文件夹结构
public_html
---- .htaccess {permission: -rw-r--r--}
---- .htpasswd {permission: -rw-r--r--}
---- adminfolder {permission: drwxr-xr-x}
---- ---- .htaccess {permission: -rw-r--r--}
---- ---- other secret files {permission: -rw-r--r--}
.htaccess 代码(adminfolder 中的那个)
AuthUserFile /home/userid/public_html/.htpasswd
AuthName "Log In"
AuthType Basic
Require valid-user
.htpasswd 代码
注意:这是我的原始密码的加密版本。
admin:zv.sqVSz3W1nk
.htaccess 代码(public_html 中的那个)
RewriteEngine On
RewriteBase /
#always use www - redirect non-www to www permanently
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTPS}s on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# hotlink protection
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain.p.ht [NC]
RewriteRule \.(jpg|jpeg|png|gif|css|js)$ - [NC,F,L]
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
# File caching is another famous approach in optimizing website loading time
<FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf|js|css|pdf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
# disable directory browsing
Options All -Indexes
# secure htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>
# secure spesific files
<Files a_secret_file.php>
order allow,deny
deny from all
</Files>
#SEO friendly linking
...
...
我检查了
- 我的完整路径信息
- 用户名 - 原始密码和加密密码
- 编码
- 我所有的文件都是用记事本++和编码的 UTF-8 准备的,没有 BOM
最后
我试过铬。我输入了用户名 + 未加密的原始密码。Chrome 要求我再次登录。
然后我清除了 IE 的所有缓存。我再次输入用户名+非加密密码。IE还要求我再次登录。
你能纠正我吗?谢谢,BR