简体   繁体   English

Symfony2使用.htaccess保护管理面板

[英]Symfony2 protect admin panel with .htaccess

i have a web project developed with Symfony2 and i would like to protect my admin panel by BOT's continuos scan. 我有一个用Symfony2开发的Web项目,我想通过BOT的持续扫描来保护我的管理面板。 Now there is just a simple authentication with username and password but i would like set also a .htaccess and .htpasswd authentication. 现在只有一个使用用户名和密码的简单身份验证,但是我还要设置一个.htaccess和.htpasswd身份验证。

Usually we have to put the .htaccess file inside the folder to protect but with Symfony2 i don't have a folder where is located the admin panel to protect. 通常,我们必须将.htaccess文件放在文件夹中进行保护,但是使用Symfony2时,我在管理面板上没有文件夹来进行保护。

I didn't found any other posts with the same issue. 我没有发现其他相同问题的帖子。 Someone known some way to do what i wrote above? 有人知道做我上面写的方法吗?

Thanks 谢谢

If you're using RESTful URLs, you're probably out of luck. 如果您使用的是RESTful URL,则可能不走运。

Apache still parses the .htaccess if you create a folder path with the same names, but these will only be valid for the files actually in there and not for the REST-'fallback'. 如果您创建具有相同名称的文件夹路径,Apache仍会解析.htaccess,但这些名称仅对其中实际存在的文件有效,而对于REST-“后备”无效。 You'll have to find an symfony2-solution, eg implementing a login system and edit the corresponding files. 您将必须找到一个symfony2-solution,例如实现登录系统并编辑相应的文件。

Not sure about this, but if you have a login system and think it's not secure enough, you probably should think about your security at first. 对此不确定,但是如果您拥有登录系统并且认为它不够安全,则可能一开始应该考虑一下安全性。 However, if you still want http auth, you can do it via php also. 但是,如果您仍然想要http auth, 则也可以通过php进行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM