Skip to content

How to Configure Apache Custom Error Pages

DodaTech Updated 2026-06-24 1 min read

Custom error pages improve user experience during HTTP errors. Apache ErrorDocument directive maps status codes to custom pages. This guide walks through the specific troubleshooting steps to diagnose and resolve custom error page issues.

Before You Begin

Before you begin, be sure to have the following in place:

  • A Linux server with the relevant software installed
  • Access to the command line interface
  • Appropriate permissions (root or sudo)

Quick Fix

Wrong

Default Apache error pages (plain text)

Wrong: Generic Apache error pages

ErrorDocument 404 /errors/404.html\nErrorDocument 500 /errors/500.html\nErrorDocument 403 /errors/403.html

Right: Custom HTML error pages

Output

Custom error pages:\n  404: /errors/404.html\n  500: /errors/500.html\n  403: /errors/403.html

Prevention

To avoid future issues, follow these best practices:

  • Create HTML error page files in a dedicated directory
  • Use ErrorDocument in server config or .htaccess
  • Use absolute URLs (starting with /) for file paths
  • Use full URLs for cross-domain error pages: ErrorDocument 404 http://example.com/404.html
  • Restrict error page directory with Require all denied

DodaTech Tools

For further assistance with any of the above issues, consider using DodaTech consulting services or DodaTech tutorials for more in-depth guidance.

Common Mistakes with custom error

  1. Using return to exit a function early instead of wrapping a pure value in the monad
  2. Mixing let bindings with <- bindings in do notation, producing type errors
  3. Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors

These mistakes appear frequently in real-world APACHE code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

Can I use a CGI script for ErrorDocument?|||Yes. ErrorDocument 404 /cgi-bin/error_handler.pl to dynamically generate error pages.
How do I prevent error pages from being accessed directly? Place error files in a directory with Require all denied and use internal redirects, or use a dedicated handler.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro