I use Mason+CGI on some smaller sites where I don't need a full-blow mod_perl install. This is also useful on my server where I run multiple Mason sites off of one Apache.
I could not find a good solution to 404's w/ Mason+CGI in the documents so here goes : Problem: 1. When you assign all .html files to be handled by a .cgi that calls mason, there are no 404's on components that don't exist. Instead you get a 500 or 200 and a Mason error page. 2. Dynamic 404 messages handled by Mason under CGI 3. Getting different 404's for different autohandlers in the site Solution: - Check if file exists and send user to 404 page. - Modify $r->status() in a 404 page. - Symlink generic 404 page form every directory w/ different autohandler. To the maintainer of HTML::Mason::CGIHandler, Could we add this to its documentation? Cheers, -m -------------------------------------------------------------------- CGI Handler : mason.pl -------------------------------------------------------------------- #!/usr/bin/perl use HTML::Mason::CGIHandler; my $user = 'max'; my $comp = $ENV{'PATH_TRANSLATED'}; my $comp_root = "/home/$user/public_html"; my $data_dir = "/home/$user/mason_data"; my $e_404 = '404.html'; my $h = HTML::Mason::CGIHandler->new ( data_dir => $data_dir, comp_root => $comp_root, ); # requested an unknown file unless (-r $comp) { # try dir-specific 404 $ENV{PATH_INFO} =~ s/[^.\/]+\.html$/$e_404/; # Use /404.html if not found $ENV{PATH_INFO} = "/$e_404" unless (-r "${comp_root}$ENV{PATH_INFO}"); } $h->handle_request; -------------------------------------------------------------------- -------------------------------------------------------------------- 404.html -------------------------------------------------------------------- <%method title> 404 Not Found \ </%method> The page you have requested does not exist. % $r->status(404); -------------------------------------------------------------------- (the title method is specific to my autohandler) -------------------------------------------------------------------- some_subdir/404.html -------------------------------------------------------------------- % cd $comp_root/some_subdir % ln -s ../404.html ------------------------------------------------------------------------- SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future. http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 _______________________________________________ Mason-users mailing list Mason-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mason-users