G'day Anthony, Anthony Ettinger wrote:
> Thanks, a dhandler is probably the best way, but how do i recognize an > error? If you hit a dhandler then one expects that all other attempts to locate the page has failed. We use a top-level dhandler to generate 404s on http://perltraining.com.au/ and to redirect pages that have moved. dhandlers in sub-directories simply decline requests they don't understand, so eventually everything all missing pages end up at the top-level dhandler. The actual code from the production site is below. Note that we must set the content type and status manually, since we can't be sure that apache will set these for us. The 'title' method is used by the autohandler. ---cut here--- <%method title> Page not found. </%method> <%doc> When nothing else works, we end up here. We start by checking to see if we have the location of an old course or other content, and issue a permanent redirect when appropriate. If not, then we display a "NOT FOUND" page and set the return status appropriately. We have to tweak the content type because it may otherwise not be set by apache. </%doc> <%init> use Apache::Constants qw(NOT_FOUND MOVED); my $request = $m->dhandler_arg; my %moved = ( 'bookings.html' => '/bookings/', 'courses.html' => '/courses/', 'books.html' => '/books/', 'bookings/All.html' => '/bookings/', ); # If it's moved, send them there immediately. if ($moved{$request}) { $m->redirect($moved{$request}, MOVED); } # Otherwise, test if it's an old course page. my $dest_url = "courses/$request"; my $comp = $m->fetch_comp($dest_url); $m->redirect($dest_url,MOVED) if $comp; # Otherwise, fall through to the 404. </%init> % $r->content_type('text/html'); % $r->status(NOT_FOUND); <p> Sorry! The page <tt>/<% $m->dhandler_arg %></tt> could not be found on this server. If you were expecting it to exist, then please <a href="/contact.html">contact us</a> and let us know. </p> ---cut here--- Cheerio, Paul -- Paul Fenwick <[EMAIL PROTECTED]> | http://perltraining.com.au/ Director of Training | Ph: +61 3 9354 6001 Perl Training Australia | Fax: +61 3 9354 2681 ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Mason-users mailing list Mason-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mason-users