Pacific Blue Software Logo

Have Custom Error Pages on Apache using .htaccess

How to have Custom Error Pages with XAMPP / Apache using .htaccess

So you want custom error pages on Apache on your production machine and/or on XAMPP for windows on your dev machine. This can be achieved by using .htaccess file.


Custom Error Pages on Xampp on Development Machine

Lets assume that your folder (website) is example.com and your xampp is installed on F:.

  1. Create/Edit the file in F:\xampp\htdocs\example.com\.htaccess
  2. Insert a line ErrorDocument 404 /example.com/404.shtml
  3. Create the file F:\xampp\htdocs\example.com\404.shtml
  4. Put whatever html you want in it.
  5. Repeat for other errors, such as 400,403 and 500.
  6. If you type in localhost/example.com/xxy and xxy.php and xxy.html do not exist then the error page will be shown

Custom Error Pages on Apache on Production Machine

Lets assume that your website is example.com.

  1. Create/Edit the file in public_html/.htaccess
  2. Insert a line ErrorDocument 404 /404.shtml
  3. Create the file public_html/404.shtml
  4. Put whatever html you want in it. Note that it's best to have absolute paths to any resources in these files. This is because they could be executed a subfolder.
  5. Repeat for other errors, such as 400,403 and 500.
  6. If you type in example.com/xxy and xxy.php and xxy.html do not exist then the error page will be shown

Have your own Custom Error Pages with XAMPP / Apache using .htaccess


Back to Articles
Protect Directories with XAMPP / Apache

If you found this useful, then please consider making a donation.

paypal
QR Code for donation Please donate if helpful