On 12/2/07, Max Baker <[EMAIL PROTECTED]> wrote: > 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; > -------------------------------------------------------------------- Hi, Max: If the '$comp' in your script is the request component, I think you can just use ErrorDocument in .htaccess or httpd.conf ErrorDocument 404 /path/to/error.html then setup dynamic content in error.html with Mason, i.e. parse $ENV{REQUEST_URI} and then send different 404 message for requests with different paths... Regards, Xicheng ------------------------------------------------------------------------- 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