on 2nd look what you suggested didn't work, it just printed the uri of the errorpage.
I found that using 'print $REDIRECT_URL' works OK. But as a cautionary note, it will only work if the errordocument url in your .htaccess file is not a full url,
ie.
ErrorDocument 404 http://trek/errorpages/error404.php
doesn't work, but
ErrorDocument 404 /errorpages/error404.php
does work.
Cheers
Jamie