Codeigniter 中的 .htpasswd

发布于 2024-09-25 10:42:22 字数 383 浏览 0 评论 0原文

你好,我想用密码保护 codeigniter 中的一个控制器。这是 .htaccess 中的代码,

# password-protect single file
<Files my_controller.php>
AuthName "my_controller.php"
AuthType Basic
AuthUserFile /home2/afolder/.htpasswds/.htpasswd
require valid-user
</Files>

问题是 myController.php 将在我的 url 中显示为 /my_controller/ (无 .php),因此保护无效...我可以做些什么吗克服这个问题? 提前致谢

Hello there I want to password protect one of my controllers in codeigniter. This is the code in .htaccess

# password-protect single file
<Files my_controller.php>
AuthName "my_controller.php"
AuthType Basic
AuthUserFile /home2/afolder/.htpasswds/.htpasswd
require valid-user
</Files>

the problem is that myController.php will show up in my url as /my_controller/ (no .php) so the protection has no effect...can I do something to overcome this problem?
thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

稳稳的幸福 2024-10-02 10:42:22

最后解决方案就这么简单...

# password-protect single file
<Files my_controller>
AuthName "my_controller"
AuthType Basic
AuthUserFile /home2/afolder/.htpasswds/.htpasswd
require valid-user
</Files>

只需删除 .php 一切都很好...

Finally the solution was as simple as that...

# password-protect single file
<Files my_controller>
AuthName "my_controller"
AuthType Basic
AuthUserFile /home2/afolder/.htpasswds/.htpasswd
require valid-user
</Files>

just removed .php and everything is fine...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文