You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Stephen Brennan <St...@elprotech.com> on 2008/11/03 04:04:32 UTC

[users@httpd] Apache - URL based environment variables

Hi all,

I am trying to figure out how to configure appache webserver to set
different UNIX environment variables depending on the url text entered.

eg.  
<base url>/A
would be required to set an enviroment variable Config=A

and
<base url>/B
would be required to set an environment variable Config=B

These two urls will share a common system directory and therefore a
common <Directory> directive.  The CGI scripts in that directory use the
environment variable to determine what database to use etc.  

I have tried with a combination of one <Directory> directive and two
<Location> directives, but the location directives are having no affect.

eg.
Alias <base url>/A <system dir>
Alias <base url>/B <system dir> 

<Directory <system dir>>
  ... 
</Directory>

<Location <base url>/A>
  SetEnv Config A
  ...
</Location>

<Location <base url>/B>
  SetEnv Config B    
  ...
</Location>

I am quite sure that this used to work in versions of apache before 2.2.

Any practical sugestions would be appreciated.

Cheers

Stephen Brennan 

PS: previous posting was sent without a subject line.

---------------------------------------------------------------------
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] Apache - URL based environment variables

Posted by Stephen Brennan <St...@elprotech.com>.
Nick,

I believe the syntax
is
RewriteEngine on;
RewriteRule <base url>/A/.* - [E=Config:A] 
RewriteRule <base url>/B/.* - [E=Config:B]

_________________________________________________
my actual setup

Alias /bugzillatest /usr/share/bugzilla
Alias /bugzillaother /usr/share/bugzilla

<Directory /usr/share/bugzilla>
  RewriteEngine on
  #RewriteRule .*bugzillaother.* -E=BugzillaDataRoot:/home/Bugzilla/data
  RewriteRule .*o.* - [E=BugzillaDataRoot:/home/Bugzilla/data]
  SetEnv webservergroup apache   
  AddHandler cgi-script .cgi
  Options +Indexes +ExecCGI +FollowSymLinks
  DirectoryIndex index.cgi
  AllowOverride Limit Options FileInfo
</Directory>

_______________________________________________

However what I am trying is not working the pattern .*other.* should
match bugzillaother but it doesn't.
The pattern .*bug.* matches and .*o.*, .*bugzilla.*, .*bugzill.* and
.*bugz.* do not.  It appears to me that the matching is being done
against a different string to what I am expecting or the pattern
matching is not working properly.

Could you please explain what is going on?

Cheers
Stephen 

-----Original Message-----
From: Stephen Brennan 
Sent: Tuesday, 4 November 2008 7:30 AM
To: users@httpd.apache.org
Subject: RE: [users@httpd] Apache - URL based environment variables

Nick,

Thank you.  Is this the best way to achieve this?  Ie. I am sure that I
have managed to do this before with Location directives.  Has this
changed?  

Would this be the correct syntax for my example?

RewriteEngine on;
RewriteRule <base url>/A/.* - E=Config:A 
RewriteRule <base url>/B/.* - E=Config:B

Cheers
Stephen

-----Original Message-----
From: Nick Kew [mailto:nick@webthing.com]
Sent: Monday, 3 November 2008 8:25 PM
To: users@httpd.apache.org
Subject: Re: [users@httpd] Apache - URL based environment variables

On Mon, 3 Nov 2008 13:04:32 +1000
"Stephen Brennan" <St...@elprotech.com> wrote:

> Hi all,
> 
> I am trying to figure out how to configure appache webserver to set 
> different UNIX environment variables depending on the url text 
> entered.

RewriteRule.

Capture the path component you want, and use it with the E flag and the
- target.

--
Nick Kew

Application Development with Apache - the Apache Modules Book
http://www.apachetutor.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





---------------------------------------------------------------------
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] Apache - URL based environment variables

Posted by Stephen Brennan <St...@elprotech.com>.
Nick,

Thank you.  Is this the best way to achieve this?  Ie. I am sure that I
have managed to do this before with Location directives.  Has this
changed?  

Would this be the correct syntax for my example?

RewriteEngine on;
RewriteRule <base url>/A/.* - E=Config:A
RewriteRule <base url>/B/.* - E=Config:B

Cheers
Stephen

-----Original Message-----
From: Nick Kew [mailto:nick@webthing.com] 
Sent: Monday, 3 November 2008 8:25 PM
To: users@httpd.apache.org
Subject: Re: [users@httpd] Apache - URL based environment variables

On Mon, 3 Nov 2008 13:04:32 +1000
"Stephen Brennan" <St...@elprotech.com> wrote:

> Hi all,
> 
> I am trying to figure out how to configure appache webserver to set 
> different UNIX environment variables depending on the url text 
> entered.

RewriteRule.

Capture the path component you want, and use it with the E flag and the
- target.

--
Nick Kew

Application Development with Apache - the Apache Modules Book
http://www.apachetutor.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





---------------------------------------------------------------------
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] Apache - URL based environment variables

Posted by Nick Kew <ni...@webthing.com>.
On Mon, 3 Nov 2008 13:04:32 +1000
"Stephen Brennan" <St...@elprotech.com> wrote:

> Hi all,
> 
> I am trying to figure out how to configure appache webserver to set
> different UNIX environment variables depending on the url text
> entered.

RewriteRule.

Capture the path component you want, and use it with the E flag
and the - target.

-- 
Nick Kew

Application Development with Apache - the Apache Modules Book
http://www.apachetutor.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