Forum OpenACS Development: Re: ADP or TCL for 404 error page

Collapse
Posted by Dave Bauer on
I did this yesterday.

If you set an adp as the global redirect for file not found you can do this

<% ns_return 404 text/plain "File not found" %>

The same thing would work in a tcl file.

In the config file:

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

make sure the 404 page points to an ADP extension.

Collapse
Posted by Eduardo Pérez on
I'm asking because I'd like it to be a default in CVS so no one has to look at this page to have OpenACS deliver an standard behavior when "Page Not Found"

Would it be OK to commit these changes to CVS HEAD and oacs-5-2 ?

Collapse
Posted by Ryan Gallimore on
You can evaluate a templated adp file for 404s with the following. This will properly return a 404 error code.

In config.tcl:

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

Create your templated adp page called 404.adp:

<master>

<h2>Sorry, that page cannot be found.</h2>

In file-not-found.adp:

<%
set rendered_page [ad_parse_template "/www/global/404"]
ns_return 404 text/html $rendered_page
%>