0

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

8
  • It's not clear what you are trying to do. can you paste what you mean by setting a DEV variable in httpd.conf? Commented May 13, 2012 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? Commented May 13, 2012 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) Commented May 13, 2012 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. Commented May 13, 2012 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. Commented May 13, 2012 at 7:43

1 Answer 1

2

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 
7
  • 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? Commented May 13, 2012 at 8:44
  • did you use setenvif to set your DEV variable? I assumed so. also updated my post to explain satisfy directive Commented May 13, 2012 at 8:49
  • I dont understand I cant just use the variable I set in httpd.conf? Commented May 13, 2012 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? Commented May 13, 2012 at 11:39
  • in httpd.conf I added this SetEnv ENV dev Commented May 13, 2012 at 18:58

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.