Re: How Do I change the Document Root Per Request

Fred Moyer <[email protected]>
Newsgroups gmane.comp.apache.mod-perl
Message-ID <CAHrynWB4XxjM__L10CJXQ10gkFomK5ZZ2arSowHMpD-TatV+eQ@mail.gmail.com>
Can you show us your relevant httpd.conf snippet? No guesses right
now, but that might help.

On Sun, Mar 1, 2015 at 4:46 PM, David E. Wheeler <[email protected]> wrote:
> Hi,
>
> I want to set the document root for a request to map to the basic auth username. I tried this in a PerlFixupHandler:
>
>     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 username subdiectory does not exist.
>         my $doc_root = File::Spec->catdir($r->document_root, $user);
>         return HTTP_FORBIDDEN unless -d $doc_root;
>
>         # Set the document root for the duration of this request and return.
>         $r->document_root($doc_root);
>         return DECLINED;
>     }
>
> But alas, it still serves the original document root. How can I get it to change the document root on a per-request basis? If I cant, should I change the URI or the filename, instead?
>
> Thnks,
>
> David
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.