David,

I am not an expert at this, so I don't have an answer.

But I can suggest a few debugging steps to clear out of the way:

1) Confirm that your document root is showing properly in the error log

Does the error log report "/var/html/foo/bar.html" is not found, or does it
only show the request? On my local apache instance if I do /blah/foo (non
existant), I get: File does not exist: /home/www/html/blah (which has my
document root in it).

2) Confirm that path exists, Look for a folder structure you can create
that will work

if /var/html/foo/bar.html doesn't exist, is it looking for
/var/www/foo/bar.html or /foo/bar.html

3) Do you have any rewrite urls or other location / directory directives
that could be overriding hits?

Check your config files, and then put in some print STDERR / smart comments
to confirm if your routing program is returning the DECLINED

4) Does it work for DirectoryIndexes?

Lathan

On Wed, Mar 11, 2015 at 12:59 PM, David E. Wheeler <da...@justatheory.com>
wrote:

> On Mar 6, 2015, at 5:29 PM, David E. Wheeler <da...@justatheory.com>
> wrote:
>
> > And now it works just how I want.
>
> I take it back. It works for files in the root, but not subdirectories.
>
> So say my document root is /var/html, and a request comes in for
> /foo/bar.html. Apache has mapped it to /var/html/foo/bar.html, but in my
> PerlTypeHandler, I re-map it to /var/html/david/foo/bar.html and set finfo:
>
>   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;
>  }
>
> I have no PerlReponseHandler, so Apache handles the response…and returns
> 404. Note that a request for /hi.txt; it’s only a request in a
> subdirectory, /foo/bar.html, that fails. Why? Why isn’t Apache able to find
> that file? Is there some other attribute of $r I need to set or unset?
>
> Thanks,
>
> David
>
>

Reply via email to