1

My Apache is rusty.

If two servers, foo and bar, use the same .htaccess file that restricts users using require group or require user, how do you base the requirement on the server? I don't think you use RewriteCond here, but I forget.


Looking for something like:

# if foo.com
require group foo 

# if bar.com
require group bar
vol7ron
  • 40,809
  • 21
  • 119
  • 172
  • 1
    This might be helpful: http://stackoverflow.com/questions/736524/how-can-i-have-a-conditional-htaccess-block – Peter Jul 19 '11 at 18:43
  • Yeah I already saw that before I posted this. It's using RewriteCond and RewriteRule, which I thought I already covered by saying `I don't think you use RewriteCond here`. I think rewrites are handled differently from authentication/permission control. – vol7ron Jul 20 '11 at 00:30
  • there's an `allow from ` and `deny from `, but I haven't seen anything like `require group from ` – vol7ron Jul 20 '11 at 00:51
  • Well, .htaccess and httpd.conf both contain directives that Apache uses to handle both rewrites and permission control. It would of course be possible to configure servers *foo* and *bar* at the httpd.conf level to use different files to control access at the directory level (e.g. .htaccess_foo and .htaccess_bar), but your question is about using the same .htaccess file for both. I'll see if I can generate (or find) an example. – Peter Jul 20 '11 at 11:10
  • @Peter: you're exactly right, furthermore, I'd to avoid modifying the httpd.conf and/or restarting apache. The heart of this problem is that the groups are not the same between servers. Instead of `foo` and `bar` it'd be better to call that group one universal name on all servers, however, when it comes to practice, idealism takes a back seat. I'll dig into it too, thx for the help – vol7ron Jul 20 '11 at 13:11
  • All the examples I've seen put Require directives inside a directive, although it looks like they ought to fit *syntactically* inside a directive, which (if it actually worked) might let you do what you want. – Peter Jul 25 '11 at 21:01

1 Answers1

0

As commented here: http://www.gossamer-threads.com/lists/modperl/modperl/93036, I could only find a Mod_Perl alternative, but I don't want to rely on that, should mod_perl be turned off in the future:

BEGIN 
{ 
    if (exists $ENV{MOD_PERL}) 
    { 
        require Apache::Constants; 
        import Apache::Constants qw(:common :http); 
    } 
} 
vol7ron
  • 40,809
  • 21
  • 119
  • 172