in reply to [mod_perl] path_info() problem

Alias /browse /home/insaniac/work/code/perl/
I'm not awake enough to parse through the rest of your problem, but let me start by saying two things.

First, an "Alias" like that one is begging for trouble. You need to have both the left and right sides of an Alias either with a slash, or without. And if you put both (which is sometimes necessary), put the pair with a slash first. Keep in mind that Alias does a literal substitition.

Second, content handlers must be very careful about how they handle being passed a directory name. If you are handed a URL that maps to a directory name, but that URL does not end in a slash, you must return DECLINED, which will cause the core directory module to issue an external redirect to the user. The updated URL from the browser will synchronize the browser's view of the directory (now ending in a slash) with your view of the directory.

I have an example of this (including this description) in my mod_perl picture handler. Specifically, examine the code for line 95, and how you would end up there (especially the DIR_MAGIC_TYPE earlier).

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re^2: [mod_perl] path_info() problem
by insaniac (Friar) on May 10, 2005 at 10:09 UTC
    thanks merlyn, removing the Alias made the code work! (and of course: the Alias line is NOT in the book, so it was my own stupid fault)

    to ask a question is a moment of shame
    to remain ignorant is a lifelong shame

        hey merlyn,
        I'm still looking at it (saw your posting last night)... but I think I still don't understand it. Why is it so important? I mean: if I add for instance ../.. (or a lot of them) to the URI, it doesn't do a thing. I mean, eventually it just shows the document_root. (and not some directory which should be protected by the webserver).

        And, I want to parse files and directories (because: I want to create a small file-browser which can handle text files and images. The images i want to display, and for the text files i want a minimal syntax highlighting display).. so if I add that line 95 to my code (maybe on the wrong spot in my code), I also have to add a slash to my files. Is that normal? I mean: a URI like http://somehost/file.txt/ seems weird to me (but who am i)
        But ok, you said: how they handle being passed a directory name.. Also: adding the DECLINE renders a "File Not Found" on my server. So if I want to use your tip, if need to add a slash at the end of each link i create (like the <a href="$location/">).
        But like I said: I probably don't understand what you mean..

        I've put my updated code (with the syntax highlighting mess) in my scratchpad, if someone's interested.

        Either way: thank you for pointing me at stuff I read to quickly (or failed to read). It's a bad habit of me.. ack.

        to ask a question is a moment of shame
        to remain ignorant is a lifelong shame