I’m trying to change the default Apache 404 message/page on my lab computer. Here, I will share my experience though it is simple.

Environment

  • OS: Arch Linux
  • Apache Server

404 Template

I found some good-looking templates on 20 Best Easy To Use Free 404 Error Page Templates. They are free and well-designed, and I chose one of them which is my cup of tea.

Configuration

The only thing I need to do is to modify the configuration file of Apache httpd. i.e. /etc/httpd/conf/httpd.conf file in my computer.

According to the guidance in httpd.conf file, custom your error page like this:

1
2
3
4
5
ErrorDocument 500 "Sorry, our script crashed. Oh dear"
ErrorDocument 500 /cgi-bin/crash-recover
ErrorDocument 500 http://error.example.com/server_error.html
ErrorDocument 404 /errors/not_found.html
ErrorDocument 401 /subscription/how_to_subscribe.html

There is a setting which implements multi-language error documents through content-negotiation. It will prevent the error page setting from working properly. Comment out the include:

1
2
# Multi-language error messages
#Include conf/extra/httpd-multilang-errordoc.conf

Restart the http.service.

Done!

Renderings show