Using .htaccess to set a custom 404 page

Posted by George

This should be a decent, if short, follow-up for the recent post about using PHP for redirects. If you want to build a custom 404 page to avoid visitors seeing whatever 404 page their browser presents then try this in your .htaccess file:

ErrorDocument 404 /notfound.html

Or maybe you don’t want to actually build a custom 40, but you still don’t want visitors to see their browser’s default 404 message, then just send them to your home page:

ErrorDocument 404 /index.html (or whatever your home page is named)

Just don’t forget to update this entry if you ever change your home page name!

RELATED POSTS

Tags: , , ,

Posted in Web Design by George | 1 Comment

1 Comment "Using .htaccess to set a custom 404 page"

Leave a Comment