Custom error pages

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Ree
Forum Regular
Posts: 592
Joined: Fri Jun 10, 2005 1:43 am
Location: LT

Custom error pages

Post by Ree »

Is it possible to redirect a user to a custom error page using PHP only in case some server error happens (such as 404)? Or is it only possible by configuring Apache itself? I'm asking this since I would like to have this functionality on shared hosts which do not allow server configuration.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

last I saw, shared hosts often pointed to a 404 page in your document root..
Ree
Forum Regular
Posts: 592
Joined: Fri Jun 10, 2005 1:43 am
Location: LT

Post by Ree »

You mean, if I put my own 404 page in the docroot, it would be used instead of the server default one?
User avatar
hanji
Forum Commoner
Posts: 46
Joined: Fri Apr 29, 2005 3:23 pm

Post by hanji »

You may be able to add a .htaccess file in your webroot. I'm not 100% sure if this will work at the htaccess level, but this is standard vhost configuration option on Apache. Of course.. this is assuming that your site is running on Apache webserver...

Code: Select all

ErrorDocument 404 http://www.yoursite.com/error.htm
ErrorDocument 403 http://www.yoursite.com/error.htm
Hope this helps
hanji
Post Reply