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 2, 2015, at 8:27 PM, Fred Moyer <[email protected]> wrote:

> Can you show us your relevant httpd.conf snippet? No guesses right
> now, but that might help.

Sure.

    PerlLoadModule My::UserFixup
    <Location />
        PerlFixupHandler  My::UserFixup
        AuthType          Basic
        AuthName          "User File Service"
        Require           valid-user
    </Location>

There’s also a simple PerlAuthenHandler. Pretty simple stuff.

I’ve gotten a little further since my post on Friday, changing the filename instead of the doc_root:

   sub handler {
       my $r = shift;

       # We only want to do this once per request.
       return DECLINED unless $r->is_initial_req;

       # Get the username.
       my $user = $r->user or return HTTP_UNAUTHORIZED;

       # Return forbidden if the subscriber ID subdirectory does not exist.
       my $doc_root = $r->document_root;
       my $sub_root = File::Spec->catdir($doc_root, $user);
       return HTTP_FORBIDDEN unless -d $sub_root;

       # Set the filename.                                                                  
       my $file = File::Spec->catfile($sub_root, substr $r->uri, 1);
       $r->filename($file);
       $r->finfo(APR::Finfo::stat($file, APR::Const::FINFO_NORM, $r->pool));
       return DECLINED;
  }

This works for root requests (/), but not anything else, which always return 404. It’s driving me crazy. Maybe there’s something else i need to set? This has *got* to be a common thing people do, right? It’s driving me bananas (and towards Plack [again!]).

Thanks,

David
smime.p7s (application/pkcs7-signature, 4 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.