How can I make custom 404 pages?

I’d like to serve my own HTML for 404 (and other HTTP codes).

You will have to include lines for handling 404 response codes in your application code. In a Python web framework like Django, include it in a file.

from django.shortcuts import render_to_response
from django.template import RequestContext

def handler404(request, exception, template_name="404/index.html"):
    response = render_to_response("404/index.html")
    response.status_code = 404
    return response

and then update

handler404 = 'my_app.views.handler404'


In PHP you can include it in your main passthru file in the application directory, index.php. Within that file, you can then point to the custom 404 html file: