You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Jan Sievers <si...@zedat.fu-berlin.de> on 2007/11/22 21:23:22 UTC

[users@httpd] Environment variables with UserDir and failed requests

Hi everybody,

I am struggling a bit with an issue around (apache) environment
variables. I am using an environment variable for logging purposes and
everything works fine, except in the case of an request for a
mod_userdir resource (e.g. GET /~username/something.html) that fails
(e.g. response code 404).

I set the variable USERPAGE_USER via SetEnvIfNoCase or RewriteRule and
can see that it is correctly set using directives like

RewriteCond %{ENV:USERPAGE_USER} ^(.+)$
RewriteRule ^.*$ - [E=FOUND_USER:%1]

and watching the rewrite.log file of mod_rewrite.

However after the internal redirect to the ErrorDocument handler (a cgi
script) but before the handling of this request this environment
variable is cleared.

To make it clear. It works for me if
 * the request is successful (200)
 * the request is not a UserDir-request (not ~username) and fails
 * the request is not a UserDir-request (not ~username) and succeeds


My Apache version is: 2.0.54

Down is a sample log part (sorry it's ugly).

Can you see any reason for that?
Do I do something wrong?

Thanks in advance,
jan


== rewrite.log ==

[domain.ttl/sid#817bcd8][rid#81d81a0/initial] (2) init rewrite engine
with requested uri /~username/test.html

--> Now comes the global test for USERPAGE_USER.

[domain.ttl/sid#817bcd8][rid#81d81a0/initial] (3) applying pattern
'^.*$' to uri '/~username/test.html'
[domain.ttl/sid#817bcd8][rid#81d81a0/initial] (4) RewriteCond: input=''
pattern='^(.+)$' => not-matched

<-- First no match, that's fine.
--> Now comes the global match and setting of USERPAGE_USER.

[domain.ttl/sid#817bcd8][rid#81d81a0/initial] (3) applying pattern
'^.*$' to uri '/~username/test.html'
[domain.ttl/sid#817bcd8][rid#81d81a0/initial] (4) RewriteCond:
input='/~username/test.html' pattern='^/?~([a-z0-9]{3,8})/.*$' =>
matched [domain.ttl/sid#817bcd8][rid#81d81a0/initial] (5) setting env
variable 'USERPAGE_USER' to 'username'

<-- It is set.

[domain.ttl/sid#817bcd8][rid#81d81a0/initial] (1) pass through
/~username/test.html [domain.ttl/sid#817bcd8][rid#81d81a0/initial] (3)
[per-dir /home/[a-z]/*/public_html/] applying pattern '^.*$' to uri
'/home/u/username/public_html/test.html'

--> Local test in UserDir Directory directive

[domain.ttl/sid#817bcd8][rid#81d81a0/initial] (4) RewriteCond:
input='username' pattern='^(.+)$' => matched
[domain.ttl/sid#817bcd8][rid#81d81a0/initial] (5) setting env variable
'FOUND_USER' to 'username'

<-- matched as expected.

[domain.ttl/sid#817bcd8][rid#81d81a0/initial] (1) [per-dir
/home/[a-z]/*/public_html/] pass through
/home/u/username/public_html/test.html
[domain.ttl/sid#817bcd8][rid#81d7218/initial/redir#1] (2) init rewrite
engine with requested uri /error/error.pl

--> Global test again.

[domain.ttl/sid#817bcd8][rid#81d7218/initial/redir#1] (3) applying
pattern '^.*$' to uri '/error/error.pl'
[domain.ttl/sid#817bcd8][rid#81d7218/initial/redir#1] (4) RewriteCond:
input='' pattern='^(.+)$' => not-matched

<-- It is empty and that's my problem!

[domain.ttl/sid#817bcd8][rid#81d7218/initial/redir#1] (3) applying
pattern '^.*$' to uri '/error/error.pl'
[domain.ttl/sid#817bcd8][rid#81d7218/initial/redir#1] (4) RewriteCond:
input='/error/error.pl' pattern='^/?~([a-z0-9]{3,8})/.*$' => not-matched
[domain.ttl/sid#817bcd8][rid#81d7218/initial/redir#1] (1) pass through
/error/error.pl
[domain.ttl/sid#817bcd8][rid#81d7218/initial/redir#1] (3) [per-dir
/var/www/meta-doc/bin/error/] strip per-dir prefix:
/var/www/meta-doc/bin/error/error.pl -> error.pl
[domain.ttl/sid#817bcd8][rid#81d7218/initial/redir#1] (3) [per-dir
/var/www/meta-doc/bin/error/] applying pattern '^.*$' to uri 'error.pl'
[domain.ttl/sid#817bcd8][rid#81d7218/initial/redir#1] (4) RewriteCond:
input='' pattern='^(.+)$' => not-matched
[domain.ttl/sid#817bcd8][rid#81d7218/initial/redir#1] (3) [per-dir
/var/www/meta-doc/bin/error/] strip per-dir prefix:
/var/www/meta-doc/bin/error/error.pl -> error.pl
[domain.ttl/sid#817bcd8][rid#81d7218/initial/redir#1] (3) [per-dir
/var/www/meta-doc/bin/error/] applying pattern '^.*$' to uri 'error.pl'
[domain.ttl/sid#817bcd8][rid#81d7218/initial/redir#1] (4) RewriteCond:
input='' pattern='^.*[a-z0-9]{3,8}.*$' => not-matched
[domain.ttl/sid#817bcd8][rid#81d7218/initial/redir#1] (1) [per-dir
/var/www/meta-doc/bin/error/] pass through
/var/www/meta-doc/bin/error/error.pl

---------------------------------------------------------------------
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