Handle errors and return proper 404 pages