Cakephp 使用 htaccess 和 htpasswd 进行密码保护 - 如何?
在 Cakephp 中使用 htaccess 开发期间如何使用密码保护我的网站?
- 我必须更改哪个 htaccess 文件?
- 我必须在 htaccess 中写什么,
- 我要把 .htpasswd 放在哪里?
我在谷歌上搜索过,但找不到任何有用的东西,我希望你能帮助我!
谢谢直到帮助我解决了问题!
对于 CakePHP 用户: - 修改/app/webroot/中的.htaccess - 在 .htaccess 文件的开头添加类似的内容:
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /complete/path/to/.htpasswd
AuthGroupFile /dev/null
require valid-user
现在在 /app/webroot/ 中创建 .htpasswd 文件,然后将类似的内容放入:
admin:PASSWORD
“PASSWORD”是我创建的真实密码的转换版本使用此工具: http://tools.dynamicdrive.com/password/
我认为有有很多方法可以创建它,但对我来说它有效,也许这也可以帮助其他 cakephp 用户。
How can I password protect my website during development with htaccess in Cakephp?
- which htaccess file do I have to change?
- what do I have to write in the htaccess
- where do I put the .htpasswd?
I searched google for that but couldn't find anything useful, I hope you could help me!
Thanks Till that helped me solve the problem!
For CakePHP-Users:
- Modify the .htaccess in /app/webroot/
- add something like that at the beginning of the .htaccess-file:
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /complete/path/to/.htpasswd
AuthGroupFile /dev/null
require valid-user
Now create the .htpasswd-File in /app/webroot/ and drop something like this in:
admin:PASSWORD
The "PASSWORD" is a transformed version of your real password, I created it with this tool: http://tools.dynamicdrive.com/password/
I think there are much more ways to create this, but for me it worked and maybe this helps other cakephp users too.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的文档根目录中可能有一个
.htaccess
,因此如果您想保护整个网站,您可以添加到此文件,因为它是第一个。 否则,在您要保护的目录中添加.htaccess
文件。然后,查看此操作方法:
http://httpd.apache.org/docs/2.2/howto/auth.html
简而言之,这就是您添加的内容:
添加用户的命令是:
无论如何,请务必阅读上面的操作方法!
You probably have a
.htaccess
in your document root, so you would add to this file since it's the first so to speak -- if you want to protect the entire website. Otherwise add a.htaccess
file in the directory you wish to protect.Then, check out this howto:
http://httpd.apache.org/docs/2.2/howto/auth.html
In a nutshell, this is what you add:
The command to add users is:
Make sure you read the above howto anyway!
http://snook.ca/archives/servers/password_protect_admin/
第一个链接包含信息关于在蛋糕应用程序中使用 .htaccess 安全性。 这些评论包括“hackish”。 有关如何仅针对管理路由执行此操作的解决方法。
http://snook.ca/archives/servers/password_protect_admin/
The first link has information on using .htaccess security from within cake apps. The comments include a >hackish< workaround on how to do this for only the admin routes.