如何将htpasswd放在magento管理面板中


How to put htpasswd in magento admin panel?

我试图在magento管理面板中添加.htpasswd。我已经在 magento 根目录中上传了这两个文件。但是我的密码提示框也是前端。

请检查并帮助我如何仅为 magento 管理员而不是前端实现 .htpasswd?

.htaccess

AuthType Basic
AuthName "Password Protected Area"
AuthUserFile /home/xxxxx/public_html/.htpasswd
Require valid-user

.htpasswd

foo:$apr1$yB1.9vIT$IVVBmq5vMauwsNR8CZdHQ.  //foo and bar

.htaccess 默认适用于它所在的目录,在本例中是 Magento 的所有目录。

Magento没有可以保护的物理管理文件夹,因此最好的选择是使用Apache的LocationMatch指令

    <LocationMatch "^/admin">
        AuthType Basic
        AuthName "Password Protected Area"
        AuthUserFile /home/xxxxx/public_html/.htpasswd
        Require valid-user
    </LocationMatch>

请注意,上述配置未经测试

编辑:值得注意的是,将管理路径从"管理员"更改为更安全的路径也是一个好主意。