1

Is it possible to block just frontend with htaccess? If I setup normal htaccess authentication to root then it block uploading images from admin.

I'm aware there is IP blocking possibility but htaccess authentication works way better for us.

3

You can use the IP and Authentication together

Below I have two ip's incase you needed an example for how to handle additional.

If your image upload is hitting the authentication still then you should use your server's actual IP address instead of the localhost IP.

AuthName "Authorized users only"
AuthType Basic 
AuthUserFile /root/web/html/.htpasswd
AuthGroupFile /dev/null
Require Valid-user
Order deny,allow
Allow from 127.0.0.1
Allow from 127.0.0.2
Deny from all
Satisfy any

By Default Magento Adds these lines in your default .htaccess file
The directives below override any other directives you make above or below it.

############################################
## By default allow all access

#    Order allow,deny
#    Allow from all
1

you can actually do a combination of password and ip protection. That way, you can allow access from the loopback address which should then solve your issue with the image uploading.

Here is an example for apache < 2.4:

AuthUserFile /path/to/.htpasswd
AuthName "Auth Name"
AuthType Basic

require valid-user
order deny,allow
deny from all
allow from 127.0.0.1
#aalom from ::1 # ipv6 loopback address
satisfy any

it's also possible, that your server communicates with itself over it's public ip (or even another), then you have to allow this address also

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.