apache2 REQUEST_FILENAME

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

apache2 REQUEST_FILENAME

ovar
Hi,

I'm not really a C expert, so I need a little help.

The documentation for apache on some places mentions server variable REQUEST_FILENAME. I was trying to print it out with my PHP script, but it looks like it's always empty. On the other hand, REQUEST_URI gives me what I expect. I was grepping a little in httpd-2.0.54 sources and found no place wher REQUEST_FILENAME is set (grep -r REQUEST_FILENAME *). REQUEST_URI seems to be set here (I'm not sure, I really don't code C (-: ):

server/util_script.c:    apr_table_setn(e, "REQUEST_URI", original_uri(r));

So do you know where I can find and fix(?) the mechanism of setting REQUEST_FILENAME (on my Linux server with PHP module 4.3.11 probably broken)?

Thanks!

Ovar


---------------------------------------------------------------------
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: [hidden email]
   "   from the digest: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: apache2 REQUEST_FILENAME

Joshua Slive
On 4/28/05, ovar <[hidden email]> wrote:
> Hi,
>
> I'm not really a C expert, so I need a little help.
>
> The documentation for apache on some places mentions server variable REQUEST_FILENAME. I was trying to print it out with my PHP script, but it looks like it's always empty. On the other hand, REQUEST_URI gives me what I expect. I was grepping a little in httpd-2.0.54 sources and found no place wher REQUEST_FILENAME is set (grep -r REQUEST_FILENAME *). REQUEST_URI seems to be set here (I'm not sure, I really don't code C (-: ):
>
> server/util_script.c:    apr_table_setn(e, "REQUEST_URI", original_uri(r));
>
> So do you know where I can find and fix(?) the mechanism of setting REQUEST_FILENAME (on my Linux server with PHP module 4.3.11 probably broken)?

If I remember correctly, REQUEST_FILENAME is set only by mod_rewrite, so
RewriteEngine On
will probably activate it.

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: [hidden email]
   "   from the digest: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: apache2 REQUEST_FILENAME

ovar
In reply to this post by ovar
> If I remember correctly, REQUEST_FILENAME is set only by mod_rewrite, so
> RewriteEngine On
> will probably activate it.

Hm, didn't work for me. Empty even with "RewriteEngine On" (in appropriate virtualhost). And I really don't see the place in sources where REQUEST_FILENAME is set.

modules/ssl/ssl_engine_vars.c:                 strcEQ(var, "REQUEST_FILENAME"))
modules/arch/netware/mod_nw_ssl.c:            else if (strcEQ(var, "REQUEST_FILENAME"))
modules/mappers/mod_rewrite.c:             strcasecmp(var, "REQUEST_FILENAME") == 0  ) {

These are just comparisons, right?

r.


---------------------------------------------------------------------
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: [hidden email]
   "   from the digest: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: apache2 REQUEST_FILENAME

Joshua Slive
On 4/29/05, ovar <[hidden email]> wrote:

> > If I remember correctly, REQUEST_FILENAME is set only by mod_rewrite, so
> > RewriteEngine On
> > will probably activate it.
>
> Hm, didn't work for me. Empty even with "RewriteEngine On" (in appropriate virtualhost). And I really don't see the place in sources where REQUEST_FILENAME is set.
>
> modules/ssl/ssl_engine_vars.c:                 strcEQ(var, "REQUEST_FILENAME"))
> modules/arch/netware/mod_nw_ssl.c:            else if (strcEQ(var, "REQUEST_FILENAME"))
> modules/mappers/mod_rewrite.c:             strcasecmp(var, "REQUEST_FILENAME") == 0  ) {
>
> These are just comparisons, right?

If you look at that section of the code in mod_rewrite, you'll see
that mod_rewrite makes that variable available to its
variable-expansion mechanism, but doesn't actually set it in the
environment.  Hence it is only available for mod_rewrite.

You may be able to force it into the environment, using something like

RewriteCond %{REQUEST_FILENAME} (.*)
RewriteRule .* - [E=REQUEST_FILENAME:%1]

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: [hidden email]
   "   from the digest: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: apache2 REQUEST_FILENAME

ovar
In reply to this post by ovar
> If you look at that section of the code in mod_rewrite, you'll see
> that mod_rewrite makes that variable available to its
> variable-expansion mechanism, but doesn't actually set it in the
> environment.  Hence it is only available for mod_rewrite.
>
> You may be able to force it into the environment, using something like
>
> RewriteCond %{REQUEST_FILENAME} (.*)
> RewriteRule .* - [E=REQUEST_FILENAME:%1]
>
> Joshua.

Great! I very much appreciate your suggestions. Now I'm getting further. :-)

All this originated in (from my point of view) counterintuitive behaviour regarding this variable. I probably grasped wrong this statement from documentation ( http://httpd.apache.org/docs-2.0/mod/mod_rewrite.html ):

REQUEST_FILENAME  The full local filesystem path to the file or script matching the request.

While the filesystem location of my script is "/home/www/default/t.php", the content of this variable gained using your suggestion and PHP code:

<?
echo $_SERVER['REQUEST_FILENAME'];
?>

is "/t.php" - as being related to DocumentRoot.

Is the mentioned documentation wrong or the hiccup resides in my english? :-)

Anyway, thanks!

Ovar


---------------------------------------------------------------------
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: [hidden email]
   "   from the digest: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: apache2 REQUEST_FILENAME

Joshua Slive
On 4/29/05, ovar <[hidden email]> wrote:

> All this originated in (from my point of view) counterintuitive behaviour regarding this variable. I probably grasped wrong this statement from documentation ( http://httpd.apache.org/docs-2.0/mod/mod_rewrite.html ):
>
> REQUEST_FILENAME  The full local filesystem path to the file or script matching the request.
>
> While the filesystem location of my script is "/home/www/default/t.php", the content of this variable gained using your suggestion and PHP code:
>
> <?
> echo $_SERVER['REQUEST_FILENAME'];
> ?>
>
> is "/t.php" - as being related to DocumentRoot.
>
> Is the mentioned documentation wrong or the hiccup resides in my english? :-)

The documentation is probably incomplete or wrong.

I wouldn't be surprised if REQUEST_FILENAME did contain the full path,
but only if it was checked inside a <Directory> section or .htaccess
file.  This is because it will depend on what stage of processing
mod_rewrite is running in.

In general, asking apache to tell you the exact physical location that
a request maps to on the filesystem is not easy.  This is because
mapping from URL to the filesystem can happen in so many different
ways.  You are probably better off teaching your script how do it with
your own knowledge of local rules.

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: [hidden email]
   "   from the digest: [hidden email]
For additional commands, e-mail: [hidden email]