Re: How Do I change the Document Root Per Request
"David E. Wheeler" <[email protected]>
| Newsgroups | gmane.comp.apache.mod-perl |
|---|---|
| Message-ID | <[email protected]> |
On Mar 6, 2015, at 9:21 AM, David E. Wheeler <[email protected]> wrote: >> >> PerlMapToStorageHandler Apache2::Const::OK >> >> Otherwise it just fails super early. By adding this line, I am able to freely set the filename later. > > Alas, this does *not* work for directory requests, just files. Directories return 404. Is there some other attribute other than filename and finfo I need to set so that, when I decline a request, Apache will find the directory and use mod_autoindex to display it? It does do so if I remove the above PerlMapToStorageHandler statement, so there must be some crucial attribute that needs settings for it to find a directory, right? I managed to fix this by changing my handler to a fixup handler and not setting any request handler at all. The fixup handler returns OK for HTML requests (it uses content negotiation and a GET param to decide what to return) and installs a relevant handler for other formats: return OK if $format eq 'html'; $r->handler('modperl'); if ($format eq 'json') { $r->set_handlers(PerlResponseHandler => \&handle_json); } elsif ($format eq 'xml') { $r->set_handlers(PerlResponseHandler => \&handle_xml); } elsif ($format eq 'text') { $r->set_handlers(PerlResponseHandler => \&handle_text); } And now it works just how I want. Thanks, David
smime.p7s
(application/pkcs7-signature, 4 KB) - not displayed