Normalize file URL before generating and handle 404 error