1

I am using Django + Apache via FastCGI, having this code in error handler:

def handler404(request):
    response = render_to_response('errors/404.html', locals(), context_instance=RequestContext(request))
    response.status_code = 404
    return response

I fetch invalid URL, see my custom 404 page, but there is something like this in apache access log:

- - [29/May/2011:15:10:29 -0700] "GET /qqq HTTP/1.1" 200 1316 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17"

Is it possible to have 404 code in Apache to tell, search engine crawlers, for example, that this page is not available? Thanks!

dbf
  • 6,399
  • 2
  • 38
  • 65
  • Another question shows how to achieve what you're after, though one of the answers does mention explicitly setting the status_code to 404. That is why I'm not voting to close as a duplicate. http://stackoverflow.com/questions/1812470/django-custom-handler404-shows-404-but-gives-header-200 – Josh Smeaton May 29 '11 at 22:19
  • I tried proposed solution with render_to_string, but still see code=200 in apache's logs – dbf Jun 02 '11 at 20:06

0 Answers0