php - 为什么 .htaccess 和 .htpasswd 不接受我的登录信息

标签 php apache .htaccess .htpasswd

我的问题

为什么 .htaccess 和 .htpasswd 不接受我的登录信息?

我的资源来学习我应该做什么

  1. http://www.addedbytes.com/blog/code/password-protect-a-directory-with-htaccess/
  2. 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代码(admin文件夹下的那个)

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
...
...

我检查过

  1. 我的完整路径信息
  2. 用户名 - 原始密码和加密密码
  3. 编码
  4. 我所有的文件都是用 Notepad++ 编写的,并且没有BOM编码的UTF-8

最后

我试过 chrome。我输入了用户名+未加密的原始密码。 Chrome 要求我重新登录。

然后我清除了 IE 的所有缓存。我再次输入用户名+非加密密码。 IE 还要求我重新登录。

你能纠正我吗?谢谢,BR

最佳答案

这个问题是因为您的服务器可能使用不同的算法来加密/解密密码,您可以通过不同的算法测试不同的密码组合,以找出正确的密码。

请看这个网站:http://aspirine.org/htpasswd_en.html

它使用 JavaScript 生成密码,出于安全原因,您可以保存页面并在本地运行。

请查看Apache htpasswd

关于php - 为什么 .htaccess 和 .htpasswd 不接受我的登录信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15785765/

相关文章:

.htaccess - htaccess规则获取和设置域名后面的参数

php - 域之间加一个点

php - 使用 mod_rewrite 在 htaccess 中为 Codeigniter 强制使用 https ://www.

php - WordPress 的 while 循环中的第一篇文章

php - 在 mysql 中搜索多个值

php - 如何使用递归函数嵌套对评论的回复

apache - 如果域不正确,则重定向

php - 按 "x Days Old"列出结果

java - Apache FOP 和 Arial 字体

apache - 加载 Apache2 mod_xml2enc 时 undefined symbol