在Cakephp中使用htaccess在开发过程中如何用密码保护我的网站?
How can I password protect my website during development with htaccess in Cakephp?
- 我必须更改哪个 htaccess 文件?
- 我必须在 htaccess 中写什么
- 我应该把 .htpasswd 放在哪里?
我在谷歌上搜索过,但没有找到任何有用的东西,希望你能帮助我!
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 用户:- 修改/app/webroot/中的.htaccess- 在 .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-File 并将如下内容放入:
Now create the .htpasswd-File in /app/webroot/ and drop something like this in:
admin:PASSWORD密码"是您真实密码的转换版本,我用这个工具创建了它:tools.dynamicdrive/password/
The "PASSWORD" is a transformed version of your real password, I created it with this tool: tools.dynamicdrive/password/
我认为有更多的方法来创建它,但对我来说它有效,也许这对其他 cakephp 用户也有帮助.
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.
然后,查看此操作方法:httpd.apache/docs/2.2/howto/auth.html
Then, check out this howto: httpd.apache/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请务必阅读以上操作方法!
Make sure you read the above howto anyway!
更多推荐
Cakephp 密码保护与 htaccess 和 htpasswd
发布评论