Cakephp密码保护与htaccess和htpasswd - howto? [英] Cakephp Password Protection with htaccess and htpasswd - howto?

查看:175
本文介绍了Cakephp密码保护与htaccess和htpasswd - howto?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Cakephp中使用htaccess进行开发时密码保护我的网站?

How can I password protect my website during development with htaccess in Cakephp?


  • 哪些htaccess档案需要变更? li>
  • 我需要在htaccess中写什么

  • 我在哪里放置.htpasswd?

我搜索google,但找不到任何有用的东西,希望你能帮助我。

I searched google for that but couldn't find anything useful, I hope you could help me!


感谢Till帮助我解决了这个问题!

Thanks Till that helped me solve the problem!

对于CakePHP用户:
- .htaccess在/ app / webroot /
中 - 在.htaccess文件的开头添加类似的内容:

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

现在在/ app / webroot /中创建.htpasswd-文件,并将如下内容放入:

Now create the .htpasswd-File in /app/webroot/ and drop something like this in:

admin:PASSWORD



< PASSWORD是真实密码的转换版本,我使用此工具创建了它: http://tools.dynamicdrive。 com / password /

我认为有更多的方法来创建这个,但对我来说它工作,也许这有助于其他cakephp用户。 p>

I think there are much more ways to create this, but for me it worked and maybe this helps other cakephp users too.

推荐答案

您可能在文档根目录中有 .htaccess 添加到此文件,因为它是第一如此说 - 如果你想保护整个网站。否则在您要保护的目录中添加 .htaccess 文件。

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.

然后,查看以下内容:
http://httpd.apache.org/docs/2.2/howto/auth.html

Then, check out this howto: http://httpd.apache.org/docs/2.2/howto/auth.html

简而言之,这是您添加的:

In a nutshell, this is what you add:

AuthType Basic
AuthName "dev"
AuthUserFile /complete/path/to/.htpasswd
Require valid-user

添加用户的命令是:

htpasswd -c /complete/path/to/.htpasswd yourusername

请务必阅读上述说明!

这篇关于Cakephp密码保护与htaccess和htpasswd - howto?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆