Forcing a 404 (Not Found) response within CGI script (Apache)

Forcing a 404 (Not Found) response within CGI script (Apache)

Post by Nick Per » Fri, 30 May 1997 04:00:00



I have a namespace on my server that is handles by a script vis (Apache):

ScriptAlias /foo /home/apache/cgi/fooscript

Whilst /foo/bar and /foo/bif are both valid URLs on my server, /foo/gone
isnt, and I would like my script to be able to generate a proper 404,
mainly for the benefit of spiders.  Whilst I know I could do a
semi-satisfactory 302 via:

Redirect gone /foo/gone

before the ScriptAlias directive, the namespace is really to dynamic to be
controlled through httpd.conf, which in any case would require a server
restart at regular intervals. Also, there are clearly an infinite number of
invalid urls.

I also thought about forcing a 500 Server Error, but again, it's far from ideal.

Thoughts appreciated.

Nick

--
Nick Perry   | Home / Recreation          | Work - AboarD Boats & Yachts
____________ | LONDON SW1, UK             | LONDON SW10 0TB     UK
Internet,    | http://www.amulation.co.uk | http://www.aboard.co.uk

Theatre,     -----------------------------------------------------------
Coffee, Tea, Multimedia, Macs, Photography, Print Publishing, etc, etc..

 
 
 

Forcing a 404 (Not Found) response within CGI script (Apache)

Post by Nick Per » Fri, 30 May 1997 04:00:00




>isnt, and I would like my script to be able to generate a proper 404,

And the answer is, of course, the module 'asis'. Doh. Thanks for the answers.

--
Nick Perry   | Home / Recreation          | Work - AboarD Boats & Yachts
____________ | LONDON SW1, UK             | LONDON SW10 0TB     UK
Internet,    | http://www.amulation.co.uk | http://www.aboard.co.uk

Theatre,     -----------------------------------------------------------
Coffee, Tea, Multimedia, Macs, Photography, Print Publishing, etc, etc..

 
 
 

Forcing a 404 (Not Found) response within CGI script (Apache)

Post by Nick K » Fri, 30 May 1997 04:00:00


There's absolutely no reason not to do exactly what you're suggesting:
return status 404 with CGI.

The only thing to bear in mind is that the CGI will have to produce its
own error document.   Use it - to give your human readers the error
message you'd wish them to see - and (optionally) links to where they
might like to go.

Nick Kew.

 
 
 

1. IE shows 404 page for 404 status response

After reading the subject, I'm sure you're thinking "duh...", but hear me
out.What I'm trying to do is make a custom error page, so instead of 404
errors the user sees my custom made error page. In netscape, it returns my
custom page and all works great. Then I look at it in IE5 and I see the same
bland 404 document I've seen a million times (This is the windows 404
document, not something apache returned to it). I guess what happens is IE
sees "status 404" and says "Oh, well I'll display my 404 document then". The
end result is IE users aren't seeing my custom 404 page.

Is there any way to force apache to NOT return the 404 status when a 404
error occurs, and instead just silently display my custom page like it was
the one requested?

LKembel

2. Mosaic source: Where?

3. Apache/404 (not founds)/Search Engines - how?

4. LPT and freebsd

5. Apache 1.3 : Linking to a specific page when "HTTP 404 - File not found"

6. Code for checking Status of tty port needed

7. How to replace Apache's "404 Not Found"

8. i810_audio.o

9. Redirect 404 - File not found

10. 404 File Not Found

11. 404 File not found

12. Website not found error message 404

13. Customize 404 "Not found" message by directory