0

I have tried to add .htpasswd in magento admin panel. I have uploaded both file in the magento root directory. But my password prompt box coming also frontend.

Please check and help me how to implement .htpasswd only for the magento admin not frontend?

.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
Chinmay235
  • 3,236
  • 8
  • 62
  • 93

1 Answers1

1

.htaccess by default applies to the directory it is sat inside, in this case all of Magento.

Magento doesn't have a physical admin folder that you can protect so the best option is to use Apache's LocationMatch directive

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

Please note the above config is untested

EDIT: It's worth noting that it is a good idea to change the admin path from 'admin' to something more secure as well.

Matthew
  • 596
  • 1
  • 8
  • 29