Forum Moderators: coopster & phranque

Message Too Old, No Replies

403s. 404s, and breaking the shackles

...or the joy of Error

         

littleman

8:38 am on Nov 21, 2001 (gmt 0)



Back in July Ggrot pointed out that it is possible to use 404's with nph scripts as an alternative to mod_rewrite mapping. I was doing some work on a clients site and he is being hosted on a server that is very limited in what it allows. There was no mod_rewrite, no ssi, no executables allowed anywhere other than the cgi-bin, and no ability to 'AddHandler'. Overall it is a pretty oppressive setup!

I had to get my wizbang script working on 30 urls, so I did Ggrot's trick and it worked great:
ErrorDocument 404 /cgi-bin/nph-wizbang.cgi
I took the time to make the script generate a 404 header if the 404 error's uri doesn't match up to my screen just to be tidy.

So I needed to do the domain base as well as index.html. I was thinking the index page was easy, just move it out of the way and that the 404/nph take care of it, but that doesn't solve the problem of the base domain request. As luck would have it, apache was set up not to allow directory content. 403 to save the day. ;)
ErrorDocument 403 /cgi-bin/nph-wizbang.cgi

And there is is! All the glory of mod_rewrite completely through the back door!

The moral?
Who knows, but I got the job done.

Brett_Tabke

1:41 pm on Nov 21, 2001 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Now thats slick. So once apache doesn't find the file, you get direct control from the word go? eg: the browser will never see the 404? I was thinking there was a redirect in there.

littleman

4:39 pm on Nov 21, 2001 (gmt 0)



No 404/403 header will appear because the nph script is responsible for header generating. Like mod_rewrite, it is remapped internally to the nph script the browser never sees a redirect.

toadhall

5:48 pm on Nov 21, 2001 (gmt 0)

10+ Year Member



For those of wondering what nph scripts are:
"NPH = No Parsed Headers. The script undertakes to print the entire
HTTP response including all necessary header fields. The HTTPD
is thereby instructed not to parse the headers (as it would normally do)
nor add any which are missing."

[htmlhelp.com...]