Apache includes a nice feature that displays localised errors. This makes use of Server Side Includes (SSI).
When you use PHP and have it also parse .html documents, your localised errors are broken. In fact, because the initial error will generate new errors, it becomes a mess. You typically see this in your error log:
unable to include "include/top.html" in parsed file /usr/share/apache2/error/HTTP_NOT_FOUND.html.var unable to include "include/bottom.html" in parsed file /usr/share/apache2/error/HTTP_NOT_FOUND.html.var
I fixed this by using a new extension .err for the error documents.
Snippet from my apache2.conf:
AllowOverride None Options FollowSymlinks Includes AddType text/html err AddOutputFilter Includes err AddHandler type-map var Order allow,deny Allow from all LanguagePriority en cs de es fr it nl sv pt-br ro ForceLanguagePriority Prefer Fallback
Then go into /usr/share/apache2/error and rename all files to have .err.var extension (instead of .html.var):
rename 's/\.html\.var/\.err\.var/g' *
Rename the tree files in includes dir:
rename 's/\.html/\.err/g' includes/*
Finally recursively replace the strings in the type-map files too:
perl -pi -e 's/\.html/\.err/g' *
You /usr/share/apache2/error tree now looks something like this:
contact.err.var HTTP_BAD_GATEWAY.err.var HTTP_BAD_REQUEST.err.var HTTP_FORBIDDEN.err.var HTTP_GONE.err.var HTTP_INTERNAL_SERVER_ERROR.err.var HTTP_LENGTH_REQUIRED.err.var HTTP_METHOD_NOT_ALLOWED.err.var HTTP_NOT_FOUND.err.var HTTP_NOT_IMPLEMENTED.err.var HTTP_PRECONDITION_FAILED.err.var HTTP_REQUEST_ENTITY_TOO_LARGE.err.var HTTP_REQUEST_TIME_OUT.err.var HTTP_REQUEST_URI_TOO_LARGE.err.var HTTP_SERVICE_UNAVAILABLE.err.var HTTP_UNAUTHORIZED.err.var HTTP_UNSUPPORTED_MEDIA_TYPE.err.var HTTP_VARIANT_ALSO_VARIES.err.var include README
Now your localised errors should be back again, and you logs will not be flooded anymore.
Wow, thanks for those regexes talk about time-saving. I was going about insane trying to get this worked out.
On my Debian – lenny instalation I have /etc/apache2/errors.conf file, which handles the error configuration. Edit this file rather than apache2.conf.
I just found somebody retarded enough to “AddHandler php-fastcgi .php .html”, a guess what happened, when apache tried to display ssi html error page …