Domain name specific code blocks in htaccess

We have local servers, central dev, staging and production servers. However the dev and staging are password protected for obvious reasons. So after deploying any changes to the htaccess i have to manually edit the htaccess file to enable the password protection on the dev and staging server.

Is there any way to have conditional blocks based on domain name like:

if ( $domain == "dev.example.com" || $domain == "staging.example.com" ){
  AuthName "Password Protected Area"
  AuthType Basic
  AuthUserFile /somewhere/.htpasswd
  Require valid-user
}

I need to find the htaccess equivalent of the condition:

if ( $domain == "dev.example.com" || $domain == "staging.example.com" ){

}

I would appreciate the any help or pointers you guys can give.

19
задан jdphenix 20 March 2014 в 05:25
поделиться