perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Torsten Foertsch <torsten.foert...@gmx.net>
Subject Re: rewriterule, location, and perlhandler
Date Wed, 22 Jul 2009 14:27:54 GMT
On Wed 22 Jul 2009, Adam Prime wrote:
> Eric Lease Morgan wrote:
> > On Jul 22, 2009, at 12:05 AM, Adam Prime wrote:
> >
> > By first changing my Location directive to the following:
> >
> >  <Location /sandbox/semantic-web/>
> >    SetHandler perl-script
> >    PerlHandler Apache2::Alex::SemanticWeb
> >  </Location>
> >
> > And then changing my RewriteRule to this:
> >
> >   RewriteRule ^/etexts/id/(.*) /sandbox/semantic-web/?id=$1
> > [passthrough]
> >
> > I eliminate the need to have a file on my file system.
> >
> > Thank you.  oss++ * mailing_lists++
>
> If you want, it's actually possible to take this even further and
> remove rewrite completely.
>
> <Location /etexts/id/>
>    SetHandler perl-script
>    PerlHandler Apache2::Alex::SemanticWeb
> </Location>
>
> Then alter your handler's code to parse $r->uri and extract
> everything after $r->location.  (or you can use $r->path_info, if the
> /etexts/id/ actually exists in your document root).  That'll give you
> the same thing that rewrite is currently stuffing into your id
> argument.

Never use path_info unless you are very sure it is what you want. 
Path_info is made for CGI scripts where $r->filename points to the file 
containing the script.

The usage of path_info leads to action at a distance problems. Assume 
you have an empty directory DOCROOT/etexts/id and path_info s what you 
want. Later an administrator adds a file or subdirectory to that 
directory or removes the id directory. Suddenly path_info has changed 
but the handler and all libraries it uses are still the same.

substr($r->uri, length $r->location) is almost always what you need.

Torsten

-- 
Need professional mod_perl support?
Just hire me: torsten.foertsch@gmx.net

Mime
View raw message