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

Collapse
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.

/www/global/file-not-found.adp:


<%
rp_internal_redirect /www/global/404
ns_adp_abort
%>

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.

/www/global/404.adp:


<master>

<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.