Forum OpenACS Q&A: Error pages and Host Node Mapping

Posted by Ryan Gallimore on
I have a host-node mapped site with a theme. There doesn't seem to be a way to create theme-specific templated error pages for 404/500 etc errors.

Has anyone been able to set this up?

Posted by Ryan Gallimore on
In the config file:

ns_section "ns/server/${server}/redirects"
ns_param 404 "global/file-not-found.adp"

You must use an ADP file. You cannot use a tcl/adp pair so, any tcl code must be embedded in the ADP.


rp_internal_redirect /www/global/404

Note in order to use the templating system, we have to invoke the request processor. We call ns_adp_abort to avoid a tcl exception about closing the connection before the adp buffer is flushed.



<h1>Sorry, page not found</h1>

The master tag will template the page contextually, so if a file is not found in the main site, the main site theme will be used, if a file is not found in a subsite (or host node map), the subsite theme will be used.

The only remaining issue is that with this solution, a 404 response code is not actually returned.

Posted by Torben Brosten on
Example 404 error return ( '<' removed from tags so they aren't blocked/rendered ).

< %
ns_return 404 text/html {<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
title>http 404 page not found/title>
p>page not found (http 404 error)/p>

p>The page you requested is not available. /p>
p>Try from the a href="/">Home page/a>./p>

% >

Posted by Ryan Gallimore on
This is fine for a simple error page but it can't be templated with themes.