.htaccess:
SetEnvIfNoCase Host s4\.yandex\.ru$ require_auth=true
SetEnvIfNoCase Host s54\.yandex\.ru$ require_auth=true
AuthType Basic
AuthName «Access to the staging site»
AuthUserFile /data/www/yandex.ru/.htpasswd
Require valid-user
# Setup a deny/allow
Order Deny,Allow
# Deny from everyone
Deny from all
# except if either of these are satisfied
Satisfy any
# 1. a valid authenticated user
Require valid-user
# or 2. the «require_auth» var is NOT set
#Allow from env=!require_auth
Allow from env=require_auth