Xidus has asked for the wisdom of the Perl Monks concerning the following question:

Well hello. I recently installed mod_perl and the HTTP::Mason module so that i could have a project that had just .html files that contained perl code to be executed, to accomplish this i added this lines of code to my apache httpd.conf file.
LoadModule perl_module modules/mod_perl.so PerlModule HTML::Mason::ApacheHandler <Location /stuff/Kokomo> SetHandler perl-script PerlHandler HTML::Mason::ApacheHandler </Location>
After i restarted my server there were some weird side effects i couldn't explain. 1. The folder /stuff/Kokomo when surfed to does not redirect to the index.html file (like it should) and 2. An image in the header of my site got messed up ( http://coyote/stuff/Kokomo/images/Website_04.gif ) but when i comment out or remove the lines of code from the httpd.conf file the image goes back to normal (which is wierd!) Anyones help with this will be much appriciated. Thanks :D

Replies are listed 'Best First'.
Re: mod_perl and HTTP::Mason acting funky
by mreece (Friar) on Aug 29, 2006 at 20:52 UTC
    1. see Allowing Directory Requests in the mason administrators manual. you'll probably want something like PerlSetVar MasonDeclineDirs 0 in your Location segment.

    2. your images are being served by mason, and are probably coming with the leading part of the HTML from the autohandler (or similar, depending on your setup.)

    consider using a <LocationMatch ...> instead:

    <LocationMatch "\.html$"> SetHandler perl-script PerlHandler HTML::Mason::ApacheHandler PerlSetVar MasonDeclineDirs 0 </LocationMarch> <LocationMatch "(\.m(html|txt|pl)?|dhandler|autohandler)/?$"> SetHandler perl-script PerlInitHandler Apache::Constants::NOT_FOUND PerlSetVar MasonDeclineDirs 0 </LocationMatch>
    see Controlling Access via Filename Extension
      That was really useful, but i couldn't seem to find any documentation about using a location match using sub directorys, eg "/dir/dir/\.html" but that wont work. Any ideas? / This is not really perl at all is it :P /
        LocationMatch uses regex, so you would want something like <LocationMatch "/dir/dir/[^/]*\.html$"> (/dir/dir/*.html only) or <Location Match "/dir/dir/.*\.html$"> (any *.html below /dir/dir/)