Implementing your own smart 404 handler