You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Alan Little <da...@holotech.net> on 2006/03/12 13:29:24 UTC

[users@httpd] Conditional Directives

Is there a general way to make Apache directives conditional, based on
such things as environment variables, presence of a file or directory,
etc.? I'm familiar with such things as IfModule or IfDefine, but want
something more  general. I've searched all day and can't find
anything, but perhaps I'm  overlooking something.

-- 
Alan Little
Holotech Enterprises


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: Re[2]: [users@httpd] Conditional Directives

Posted by Joshua Slive <jo...@slive.ca>.
On 3/12/06, Alan Little <da...@holotech.net> wrote:
> Well, for example, all my sites are mirrored on my local machine, with
> a .loc TLD. There are things I use on the live sites that I don't need
> or want on the local mirror -- script wrapping, authentication, etc.
> It would make it easier if I could test HTTP_HOST and configure
> accordingly. The altertnative is to maintain separate .htaccess files,
> which is a PITB.
>
> I'm surprised there's no capability for this; I can't be the first
> person to have thought of it, and it seems like it would be a good
> thing to have.

The standard way to handle this is to wrap directives in
<IfDefine LocalMirror>
...
</IfDefine>
<IfDefine !LocalMirror>
...
</IfDefine>
Then start apache with -DLocalMirror on the affected machine.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re[2]: [users@httpd] Conditional Directives

Posted by Alan Little <da...@holotech.net>.
Well, for example, all my sites are mirrored on my local machine, with
a .loc TLD. There are things I use on the live sites that I don't need
or want on the local mirror -- script wrapping, authentication, etc.
It would make it easier if I could test HTTP_HOST and configure
accordingly. The altertnative is to maintain separate .htaccess files,
which is a PITB.

I'm surprised there's no capability for this; I can't be the first
person to have thought of it, and it seems like it would be a good
thing to have.

-- 
Alan Little
Holotech Enterprises

On Sunday, March 12, 2006, 11:37:52 AM, you wrote:


> On 3/12/06, Alan Little <da...@holotech.net> wrote:
>> Is there a general way to make Apache directives conditional, based on
>> such things as environment variables, presence of a file or directory,
>> etc.? I'm familiar with such things as IfModule or IfDefine, but want
>> something more  general. I've searched all day and can't find
>> anything, but perhaps I'm  overlooking something.

> Not in general.  Many similar things can be accomplished with
> mod_rewrite, but you'd need to be more specific about what you are
> trying to do.

> Joshua.

> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Conditional Directives

Posted by Joshua Slive <jo...@slive.ca>.
On 3/12/06, Alan Little <da...@holotech.net> wrote:
> Is there a general way to make Apache directives conditional, based on
> such things as environment variables, presence of a file or directory,
> etc.? I'm familiar with such things as IfModule or IfDefine, but want
> something more  general. I've searched all day and can't find
> anything, but perhaps I'm  overlooking something.

Not in general.  Many similar things can be accomplished with
mod_rewrite, but you'd need to be more specific about what you are
trying to do.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re[2]: [users@httpd] Conditional Directives

Posted by ht...@karsites.net.
Sample chapter link:

http://www.apress.com/book/supplementDownload.html?bID=275&sID=2134

:-)

Keith

In theory, theory and practice are the same;
In practice they are not. 

On Mon, 13 Mar 2006 httpd2@karsites.net wrote:

> To: users@httpd.apache.org
> From: httpd2@karsites.net
> Subject: Re[2]: [users@httpd] Conditional Directives
> 
> 
> This sample chapter from Pro Apache 3rd Edition from Apress
> details how to use embedded Perl in Apache config files.
> See the section toward the end of the chapter, titled
> 
> 'Generating on the fly and included configuration files with 
> mod_perl'
> 
> Not sure if you can do this in .htaccess files though.
> 
> Keith

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re[2]: [users@httpd] Conditional Directives

Posted by ht...@karsites.net.
This sample chapter from Pro Apache 3rd Edition from Apress
details how to use embedded Perl in Apache config files.
See the section toward the end of the chapter, titled

'Generating on the fly and included configuration files with 
mod_perl'

Not sure if you can do this in .htaccess files though.

Keith


In theory, theory and practice are the same;
In practice they are not. 

On Mon, 13 Mar 2006, Alan Little wrote:

> To: Tony Heal <us...@httpd.apache.org>
> From: Alan Little <da...@holotech.net>
> Subject: Re[2]: [users@httpd] Conditional Directives
> 
> That's interesting. Does that include .htaccess files? Could you give
> me an example of how to do it?
> 
> -- 
> Alan Little
> Holotech Enterprises
> 
> On Sunday, March 12, 2006, 11:43:57 PM, you wrote:
> 
> > Yes, apache conf file can be written in perl, so you can use if
> > statements to determine whether you want something installed or not
> > depending on whatever your criteria is.
> 
> > Tony Heal
> > Pace Systems Group, Inc.
> > 800-624-5999
> > theal@pace2020.com
> 
> > -----Original Message-----
> > From: Alan Little [mailto:darguz@holotech.net] 
> > Sent: Sunday, March 12, 2006 7:29 AM
> > To: users@httpd.apache.org
> > Subject: [users@httpd] Conditional Directives
> 
> > Is there a general way to make Apache directives conditional, based on
> > such things as environment variables, presence of a file or directory,
> > etc.? I'm familiar with such things as IfModule or IfDefine, but want
> > something more  general. I've searched all day and can't find
> > anything, but perhaps I'm  overlooking something.
> 
> 
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 
> 

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re[2]: [users@httpd] Conditional Directives

Posted by Alan Little <da...@holotech.net>.
That's interesting. Does that include .htaccess files? Could you give
me an example of how to do it?

-- 
Alan Little
Holotech Enterprises

On Sunday, March 12, 2006, 11:43:57 PM, you wrote:

> Yes, apache conf file can be written in perl, so you can use if
> statements to determine whether you want something installed or not
> depending on whatever your criteria is.

> Tony Heal
> Pace Systems Group, Inc.
> 800-624-5999
> theal@pace2020.com

> -----Original Message-----
> From: Alan Little [mailto:darguz@holotech.net] 
> Sent: Sunday, March 12, 2006 7:29 AM
> To: users@httpd.apache.org
> Subject: [users@httpd] Conditional Directives

> Is there a general way to make Apache directives conditional, based on
> such things as environment variables, presence of a file or directory,
> etc.? I'm familiar with such things as IfModule or IfDefine, but want
> something more  general. I've searched all day and can't find
> anything, but perhaps I'm  overlooking something.



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] Conditional Directives

Posted by Tony Heal <th...@pace2020.com>.
 
Yes, apache conf file can be written in perl, so you can use if statements
to determine whether you want something installed or not depending on
whatever your criteria is.

Tony Heal
Pace Systems Group, Inc.
800-624-5999
theal@pace2020.com

-----Original Message-----
From: Alan Little [mailto:darguz@holotech.net] 
Sent: Sunday, March 12, 2006 7:29 AM
To: users@httpd.apache.org
Subject: [users@httpd] Conditional Directives

Is there a general way to make Apache directives conditional, based on
such things as environment variables, presence of a file or directory,
etc.? I'm familiar with such things as IfModule or IfDefine, but want
something more  general. I've searched all day and can't find
anything, but perhaps I'm  overlooking something.

-- 
Alan Little
Holotech Enterprises


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org