PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > alt.apache.configuration > SetEnv in <Directory>
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
alt.apache.configuration Apache web server configuration issues.

SetEnv in <Directory>

Réponse
 
LinkBack Outils de la discussion
Vieux 16/01/2008, 12h01   #1
markdibley@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut SetEnv in <Directory>

Hello

I have searched all over the place, but can't find an explanation for
the following.

I am trying to set different environment variables depending on what
what directory the accessed cgi script is in.

/var/www/cgi-bin/live/report.cgi
/var/www/cgi-bin/test/report.cgi

where report.cgi simply is

print $ENV{'USERSOURCE'}

I thought by adding the following to my httpd.conf file and stopping
and then starting /etc/init.d/httpd the scripts would give me
different outputs.

<Directory "/cgi-bin/live/">
SetEnv USERSOURCE live
</Directory>
<Directory "/cgi-bin/test/">
SetEnv USERSOURCE test
</Directory>

However, I can only get the variable set if I use SetEnv OUTSIDE of
the <Directory> tags (and is therefore global). I have run httpd -t to
check the syntax and all that works. Can anyone tell me why you cannot
set specific environment variables based on the directory directive?

Thanks for your and attention

Mark
  Réponse avec citation
Vieux 16/01/2008, 12h24   #2
markdibley@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: SetEnv in <Directory>

:-)

Turns out it works if instead I use....

<Location "/cgi-bin/live/">
SetEnv USERSOURCE live
</Location >
<Location "/cgi-bin/test/">
SetEnv USERSOURCE test
</Location >

Thanks anyway

:-)
  Réponse avec citation
Vieux 17/01/2008, 18h01   #3
sean dreilinger
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: SetEnv in <Directory> (try setenvif too!)

markdibley@gmail.com wrote:
> Turns out it works if instead I use....
>
> <Location "/cgi-bin/live/">
> SetEnv USERSOURCE live
> </Location >
> <Location "/cgi-bin/test/">
> SetEnv USERSOURCE test
> </Location >


based on this excerpt from the setenvif directive documentation:
http://httpd.apache.org/docs/2.2/mod....html#setenvif

Since version 2.0.51 Apache will recognize occurrences of $1..$9 within
value and replace them by parenthesized subexpressions of regex.

you could probably avoid the hassle of the pre-arranging every possible
"usersource" into a location stanza, and just use a single line like this to
cover all cases:

SetEnvIf Request_URI "/cgi-bin/(.*?)/" USERSOURCE=$1

hth
--sean

--
sean dreilinger - http://durak.org/sean/
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 10h28.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,07855 seconds with 11 queries