I recently needed to configure how 404 file not found errors were handled in Apache. This was easily done by editing httpd.conf (search for “404” to quickly find where the relevant directives are) and changing a line of code. Here’s what it looks like by default
[cc lang="php"]# Customizable error responses come in three flavors: # 1) plain text 2) local redirects 3) external redirects # # Some examples: #ErrorDocument 500 "The server made a boo boo." #ErrorDocument 404 /missing.html #ErrorDocument 404 "/cgi-bin/missing_handler.pl" #ErrorDocument 402 http://www.example.com/subscription_info.html [/cc]
To enable a file to be called on error, just uncomment the line by removing the hash (#) and changed the path to the file you want you, e.g.
[cc lang="php"]# Customizable error responses come in three flavors: # 1) plain text 2) local redirects 3) external redirects # # Some examples: #ErrorDocument 500 "The server made a boo boo." #ErrorDocument 404 /missing.html ErrorDocument 404 "/404_notfound.php" #ErrorDocument 402 http://www.example.com/subscription_info.html [/cc]