Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am using htaccess to block all access to our dev server with the following code:

AuthType Basic
AuthName "Auth"
AuthUserFile /var/htpasswd
Require valid-user
Order allow,deny
Satisfy any

I have set a variable in Apache httpd.conf called DEV. I am using it for my config files in php but how would I use it only to use the auth when the DEV setting

share|improve this question
    
It's not clear what you are trying to do. can you paste what you mean by setting a DEV variable in httpd.conf? –  Tom H May 13 '12 at 6:17
    
I have an environmental variable that I set in httpd.conf called DEV. I want to only require authentication when that variable is set to DEV. Does that make sense? –  Jacinto May 13 '12 at 7:14
    
If you paste the full output of what you have set, that might help. (this is probably going to need both the php usage, and what you have done in httpd.conf) –  Tom H May 13 '12 at 7:20
    
It's likely that there is some "more orthodox" way to achieve what you are referring to, so you might want to state your requirements as well. –  Tom H May 13 '12 at 7:21
    
What I posted there is my entire htaccess. What I am trying to achieve is to make my dev site protected so that no one can access it. The fastest way I can think of without writing a php auth system was to use the htaccess. however if I just have this code in there then my production site requires a password to. –  Jacinto May 13 '12 at 7:43
show 3 more comments

1 Answer

if the request is not for the production environment then request auth. define "any" of these two rules as sufficient

AuthType Basic
AuthName "Auth"
AuthUserFile /var/htpasswd
allow from env=PRODUCTION
require valid-user
satisfy any
share|improve this answer
    
that did not work for me. If I create another variable based on the url it works though but is there no way to just use the variable I already have? –  Jacinto May 13 '12 at 8:44
    
did you use setenvif to set your DEV variable? I assumed so. also updated my post to explain satisfy directive –  sysfault May 13 '12 at 8:49
    
I dont understand I cant just use the variable I set in httpd.conf? –  Jacinto May 13 '12 at 9:29
    
well how did you set the variable? normally a user variable is made available through the lifetime of an http request using setenv apache module (within apache config, that is). so how did you set yours cuz i'm curious? –  sysfault May 13 '12 at 11:39
    
in httpd.conf I added this SetEnv ENV dev –  Jacinto May 13 '12 at 18:58
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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