XSSI Library

The Smart 404 Error Page
Developed by Ken Guest

Last night I realised that if anybody went directly to http://www.linux.ie/missing.html the page would display - telling the user that it was missing! (For a comparison, open up the URL http://www.linux.ie/adskfjadsfkj/

(Webmaster's Note: This is a fine point, likely to be lost on non-propeller heads. Ken is saying that since you're going directly to the missing file error page, it should tell you that it _is_ there, not that it's missing.)

So I am now using the following code to catch this, and handle it 'properly'.

<!--#if expr="\"$DOCUMENT_URI\" = \"$REQUEST_URI\"" -->


Trying to be smart, are you?


<!--#else -->

<TITLE>Missing file,

http://<!--#echo var="SERVER_NAME" --><!--#echo var="REQUEST_URI" -->


<!--#endif -->

This works because (as you have documented on your site) DOCUMENT_URI contains the name of the page being served and REQUEST_URI contains the name of the document that was requested. So if the values of both are identical then the script [in the page] knows that the page was asked for instead of the page being served to the browser because some other one does not exist. Thus solving the existential crisis!

Webmaster's Note: Ken uses a couple of sets of the code above to display the correct message on the page.


A printer-friendly version of this article is available.
This site hand-coded for your protection.