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

Create the .htaccess file

Create a new text file on your computer, and call it "htaccess.txt". Enter the following lines:

<Files .htaccess>

order allow,deny
deny from all
</Files>

ErrorDocument 404 /errordocs/error404.htm

The first part stops people viewing your .htaccess file. The second part tells Apache to redirect any 404 errors to the file "error404.htm".

Next page: Create the 404 error page