The general practice is to redirect to an error page whose name is based on the type of error code, for instance a 301 redirect would be called 301.html. You can pass url parameters for the location and you could use a small javascript to extract these parameter values. The reason why you should generally use html rather than php is that html is more robust, and should there be serious problems with the server, at least if the server can still serve static files, the errors should still work as expected.
If readability is your issue, putting this page in its own file is as best as you can hope for. You can fully expand the html in its own page, so it is readable, yet it is also equally functional. If optimization is your concern, this is not the approach you should take. There are plenty of libraries in php that will compact these files for you. In the long run, it is not worth it to you to try to squeeze everything into one line, even for a page that isn't likely to change.