Monday, December 13, 2010

404 Page on a Static Site

Here's a very quick, but very useful trick. You can catch 404 errors (page not found) on a static site and serve up a custom 404 page with a one-liner in your .htaccess file:



ErrorDocument 404 /404.php

The "/404.php" part is the path to whatever file you want to serve up as the error page.


Remember that the .htaccess file works on Apache servers only. I say "static" sites, because if you are using a CMS system already (like WordPress), there is already a system in place for catching 404 errors and this is unnecessary.

0 comments:

Post a Comment