This is a discussion on Re: return DECLINED or OK? - modperl ; Hi, J. Peng wrote: > On Fri, Feb 29, 2008 at 7:03 PM, Torsten Foertsch > wrote: > >> Example continued: The entry /var/www/a/b exists on disk either as file or as >> directory but /var/www/a/b/c does not. Then after ...
J. Peng wrote:
> On Fri, Feb 29, 2008 at 7:03 PM, Torsten Foertsch
>> Example continued: The entry /var/www/a/b exists on disk either as file or as
>> directory but /var/www/a/b/c does not. Then after MapToStorage $r->filename
>> is /var/www/a/b and $r->path_info is /c/d/e.
> Sorry I can't understand for this. If /var/www/a/b exists but
> /var/www/a/b/c not, why user requests it? What's $r->path_info? How to
> get path_info from filename? thanks again.
I'm not sure if I can help by cutting in here as I'm some what learning
Apache and modperl myself.
$r is not a file or a filename. This is Perl, remember? :-) So, $r is
a scalar variable and, to be precise, the global variable for the Apache
RequestRec object. Take a look at:
to see what Torsten meant by the "path_info".
As for /var/www/a/b/c, a user can request for a file that does not
exists. The key is what Torsten said about "walking the hierarchy".
So, if /var/www/a/b/c/d/e does not exist, it sees if /var/www/a/b/c/d
exists. If not, it tries /var/www/a/b/c/. It continues doing this,
"walking [up] the hierarchy", until it finds a match. In Torsten's
example, this would be:
Then, the RequestRec object now stores two parts. A filename
"/var/www/a/b/" and a path_info "/c/d/e". Why would you want to do
that. Well, an example that I saw in the Mason Book (Note: don't
confuse yourself with learning this right now, but I just want to
mention where I got the example from) which helped me understand this
was as follows. Say you have a news site like:
A user might request that, but it wouldn't make sense to have 365
"index.html"'s every year (ok, 366 this year :-) ). Instead, you could
do a trick above and keep going up the hierarchy until you have a
filename "/var/www/archive/news/" and a path_info
"/2008/02/29/index.html". You can then use the path_info as a query
string to some database to retrieve today's news. i.e., you don't
actually have a file sitting at:
but the user doesn't know this and probably doesn't care as long as s/he
can see today's news.
I hope this helps and I hope I didn't mess up your example, Torsten. If
so, please correct me for my benefit, as well! :-)