How to set up custom error pages in .htaccess for your Apache server (ErrorDocument)

Apache: How to set up custom error pages in .htaccess for your Apache server (ErrorDocument)

If you want to set up a custom error page (for example when a 404 error happens) you can define what file to serve in your .htaccess file

  1. ErrorDocument 500 "Show a plain text message"
  2. ErrorDocument 401 http://redirect.com/to/a/url.html
  3. ErrorDocument 404 /error_files/your_404_error_file.htm

webdevetc profile pic
webdevetc

I am a 29 year old backend web developer from London, mostly focusing on PHP and Laravel lately. This (webdevetc.com) is my blog where I write about some web development topics (PHP, Laravel, Javascript, and some server stuff). contact me here.



More...


Comments and discussion about How to set up custom error pages in .htaccess for your Apache server (ErrorDocument)

Found this interesting? Maybe you want to read some more in this series?

Or see other topics in the Apache language

Or see other languages/frameworks:
PHP Laravel Composer Apache CentOS and Linux Stuff WordPress General Webdev and Programming Stuff JavaScript
Or see random questions

What is the difference between var, let and const in Javascript?

How to pick what array_intersect function to use in PHP?

What are the SPL Iterators in PHP?

How to force gzip compression in Apache with .htaccess

How to set the timezone to UTC in .htaccess

How to reverse htmlentities() / What is the opposite of htmlentities()?

How to set up custom error pages in .htaccess for your Apache server (ErrorDocument)

How to convert between types in JS?

How to find the index of a value in an array in JS?

How to find an item by Primary Key in Eloquent, or throw a ModelNotFoundException exception if it isn't found?