Dreamhost

Looking for somewhere to host your site? Browse our PHP web hosts section!

Home > Tutorials > Custom error pages using .htaccess

Custom error pages using .htaccess

Quick jump:
Introduction
Create the .htaccess file
Create the 404 error page
Trying it out
Taking it further

Taking it further

There's several other error documents that you might wish to customise.

400 - Bad request
401 - Authorization Required
403 - Forbidden directory
404 - Page not found
500 - Internal Server Error

For each one you want to use, simply add a line to your .htaccess file and create the corresponding page.

<Files .htaccess>
order allow,deny
deny from all
</Files>

ErrorDocument 403 /errordocs/error403.htm
ErrorDocument 404 /errordocs/error404.htm
ErrorDocument 500 /errordocs/error500.htm