htaccess htpasswd 无提示
我正在尝试使用“.htaccess”和“.htpasswd”保护文件夹。
我使用 http://www.tools.dynamicdrive.com/password/ 生成文件。
将它们复制到相应的文件夹中。
当我尝试访问受保护的文件夹时,我收到登录提示。
输入不正确的登录详细信息,被发送到错误页面。
一切都好。
现在,在没有任何更改的情况下,我重新访问该页面并尝试再次登录以访问受保护的文件夹,它只是抛出一个错误,没有登录框。
如果我删除 .htaccess,我可以获得再次进入该文件夹,没有错误。
替换 .htacces 后,我再次收到错误,仍然没有登录框。
我尝试重新生成一组新文件、用户/密码组合,并对 .htaccess 进行轻微修改,只是为了尝试获取某种形式的回应。
我检查了任何字节标记,两个文件都是干净的 UTF-8。
发生了什么事?为什么我不再收到提示?
顺便说一句,日志应该在哪里?我找到的只是一些访问日志,其中没有任何有用的内容。
服务器上的站点位置
/home/labvccom/
/home/labvccom/public_html/admin/.htaccess
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /htpasswords/.htpasswd
AuthGroupFile /dev/null
require valid-user
/home/labvccom/htpasswords/.htpasswd [用户:admin | pass:password]
admin:02yd6IWnPes66
这是我在没有登录提示的情况下抛出错误时得到的页面
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 mod_fcgid/2.3.5 Phusion_Passenger/2.2.15 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at labvc.com.au Port 80
I'm trying to protect a folder using '.htaccess' and '.htpasswd'.
I used http://www.tools.dynamicdrive.com/password/ to generate the files.
Copied them to the corresponding folders.
When I attempted to access the protected folder, I got a login prompt.
Input incorrect login details, get sent to error page.
All good.
Now, without any changes, I revisit the page to try and login again to access the protected folder, and it just throws an error, there's no login box.
If I delete the .htaccess, I can get into the folder again without errors.
Upon replacing the .htacces, I get the error again, still no login box.
I have tried to regenerate a new set of files, user/pass combo, and slight modifications to .htaccess just to try get some form of response back.
I have checked for any bytemark, both files are clean UTF-8.
What's going on? Why am I not getting a prompt anymore?
On a side note, where should the log be? All I managed to find was some access logs with nothing useful in them.
Site location on server
/home/labvccom/
/home/labvccom/public_html/admin/.htaccess
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /htpasswords/.htpasswd
AuthGroupFile /dev/null
require valid-user
/home/labvccom/htpasswords/.htpasswd [user: admin | pass: password]
admin:02yd6IWnPes66
This is the page that i get when it throws the error with NO login prompt
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 mod_fcgid/2.3.5 Phusion_Passenger/2.2.15 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at labvc.com.au Port 80
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的浏览器会记住第一次登录尝试,并在 授权< /a> 标头 - 这就是您没有收到新登录提示的原因。
尝试清除授权缓存。
根本问题很可能是@openscript.ch 所暗示的。
Your browser remembers the first login attempt and send the credentials in the Authorization header - that is why you do not get a new login prompt.
Try to clear the authorization cache.
The underlying problem is most likely as @openscript.ch suggests.
我认为您的 .htpasswd 文件路径是错误的。如果不是绝对的,则将其视为相对于 ServerRoot。
尝试使用 .htpasswd 文件的绝对路径。
I think your path to the .htpasswd-File is wrong. If it is not absolute, it is treated as relative to the ServerRoot.
Try to use an absolute path to your .htpasswd-File.
您需要在要保护的文件夹内创建登录/通过 .htaccess...否则该技巧将无法按预期工作!几天前我创建了一个简单的 php 工具,可以为您创建登录名/密码。这是我的另一个项目的一部分...所以我从我的档案中为您提取了它。请注意,在Windows下,密码被清除...不是我的脚本的错误,而是Windows服务器的请求。因此,仅在运行 apache 的 UNIX、Linux 远程托管中使用它。将 apache-ht.php 放入要保护的文件夹中,然后执行它。系统会提示您创建用户/密码!完成后从文件夹中删除 apache-ht.php。你失败是因为你试图设置相对路径。这种.htaccess需要完整路径!我希望这有帮助:
apache-ht.php
You need to create login/pass .htaccess inside the folder that you want to protect... otherwise the trick will not work as wanted! I created some days ago a simple php tool that creates login/pass for you. It's a part of another my project... so I extracted it from my archive for you. Pay attention that under windows the password is sent clear... is not a bug of my script but a request by windows servers. So use only it in remote hosting with unix, linux running apache. Put apache-ht.php inside the folder you want to protect and then execute it. Be prompted to create user/pass! After done delete apache-ht.php from folder. You fail because you are trying to set relative path. This kind of .htaccess needs full path! I hope this helps:
apache-ht.php