Require login only for certain IP htaccess Apache2
Solution 1:
I found a solution:
<If "%{REMOTE_ADDR} == '0.0.0.0'">
# Require Auth
AuthUserFile /var/www/example/.htpasswd
AuthType Basic
AuthName "You must be authorised to access this service."
require valid-user
</If>