OK, to satisfy Dean I started a new thread on this subject.
Justin, how does using a php script circumvent the problem of having REQUEST_URI reset when Apache reads the .htaccess file to determine which script to execute on a 404 (or other) error? I'm missing something here, because I can't see what difference it makes whether the script is written in perl or php.
I take your point about the endless 500 loop, which could happen if guardian fails for some reason. However there are ways of breaking the loop, and I can implement one--such as making sure guardian isn't the referer. Although it might be safer just to drop the 500 guardian switch from the .htaccess file and let Apache handle that one.