Single error PHP file

ezadx10b

New Member
Messages
29
Reaction score
0
Points
1
Very useful if you point all your error pages to the same file. Save more space and easy to handle it.. rite ?
This is a sample 'REDIRECT_STATUS' to your error page. First you need to use .htaccess file to point your 'REDIRECT_STATUS' to one file. Use this code


# .htaccess file.
ErrorDocument 404 /error-msg.php
ErrorDocument 500 /error-msg.php
ErrorDocument 400 /error-msg.php
ErrorDocument 401 /error-msg.php
ErrorDocument 403 /error-msg.php
# End of file.
Now your error 404,500,400,401 and 403 have point to file /error-msg.php. Now on your error-msg.php use this php code.

<?php
$HttpStatus = $_SERVER["REDIRECT_STATUS"] ;
if($HttpStatus==200) {print "Error 200-Document has been processed and sent to you.";}
if($HttpStatus==400) {print "Error 400-Bad HTTP request ";}
if($HttpStatus==401) {print "Error 401-Unauthorized - Iinvalid password";}
if($HttpStatus==403) {print "Error 403-Forbidden Area";}
if($HttpStatus==500) {print "Error 500-Internal Server Error";}
if($HttpStatus==418) {print "Error 418-I'm a teapot! - This is a real value, defined in 1998";}
?>​
Hope this useful.
 

spacepir

New Member
Messages
41
Reaction score
2
Points
0
Wow, I wish I'd known this sooner. Now I only need one error file, and I can customize them all at once!

Thank you! Much appreciated, I will definitely be using this.
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
This is the problem with hastily-developed and poorly-implemented standards -- the 418 status actually refers to a coffee maker, not a teapot. And people wonder why we have problems developing the semantic web...
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
thank for your advise..i just copy that error from wikipedia http://en.wikipedia.org/wiki/List_of_HTTP_status_codes

Apparently you didn't understand the joke. The HTTP 418 status is officially "I'm a teapot", but the IETF standard got it wrong, historically speaking. It was part of the Hypertext Coffee Pot Control Protocol (HTCPCP) released as an RFC as an April Fool's joke in 1998, and it was just too good of a nerd joke to leave out of HTTP 1.1 (RFC 2616). Complaints like mine — that a teapot response has no place in a coffee pot protocol — are as old as HTCPCP, and may be found on IETF mailing lists everywhere.
 

ezadx10b

New Member
Messages
29
Reaction score
0
Points
1
Apparently you didn't understand the joke. The HTTP 418 status is officially "I'm a teapot", but the IETF standard got it wrong, historically speaking. It was part of the Hypertext Coffee Pot Control Protocol (HTCPCP) released as an RFC as an April Fool's joke in 1998, and it was just too good of a nerd joke to leave out of HTTP 1.1 (RFC 2616). Complaints like mine — that a teapot response has no place in a coffee pot protocol — are as old as HTCPCP, and may be found on IETF mailing lists everywhere.

im sorry.so sorry.im not a english guy..and im not born with english language.
 

ezadx10b

New Member
Messages
29
Reaction score
0
Points
1
opss forgot about this..

<Files "error-msg.php">
order allow,deny
allow from all
</Files>

just to make 403 error can see the error-msg.php..
 
Top