Results 1 to 8 of 8
Like Tree2Likes
  • 2 Post By ezadx10b

Thread: Single error PHP file

  1. #1
    ezadx10b is offline x10Hosting Member
    Join Date
    Feb 2012
    Posts
    29

    Wink Single error PHP file

    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==41 {print "Error 418-I'm a teapot! - This is a real value, defined in 1998";}
    ?>
    Hope this useful.
    spacepir and lenore23 like this.

  2. #2
    spacepir is offline x10Hosting Member
    Join Date
    Aug 2012
    Location
    Scotland, United Kingdom
    Posts
    41

    Re: Single error PHP file

    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.

  3. #3
    essellar's Avatar
    essellar is offline Community Advocate
    Join Date
    Feb 2010
    Location
    Toronto, Ontario, CA
    Posts
    1,683

    Re: Single error PHP file

    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...
    “Beware of bugs in the above code; I have only proved it correct, not tried it.” --Donald Knuth
    "It was as if its architects were given a perfectly good hammer and gleefully replied, 'neat! With this hammer, we can build a tool that can pound in nails.'" -- Alex Papadimoulis (on TheDailyWTF.com)

  4. #4
    ezadx10b is offline x10Hosting Member
    Join Date
    Feb 2012
    Posts
    29

    Re: Single error PHP file

    thank for your advise..i just copy that error from wikipedia http://en.wikipedia.org/wiki/List_of_HTTP_status_codes

  5. #5
    ezadx10b is offline x10Hosting Member
    Join Date
    Feb 2012
    Posts
    29

    Re: Single error PHP file

    Quote Originally Posted by spacepir View Post
    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.
    If u like u can add more php variable on my blog http://www.ezadblog.my/2013/01/php-server.html enjoy it.

  6. #6
    essellar's Avatar
    essellar is offline Community Advocate
    Join Date
    Feb 2010
    Location
    Toronto, Ontario, CA
    Posts
    1,683

    Re: Single error PHP file

    Quote Originally Posted by ezadx10b View Post
    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.
    “Beware of bugs in the above code; I have only proved it correct, not tried it.” --Donald Knuth
    "It was as if its architects were given a perfectly good hammer and gleefully replied, 'neat! With this hammer, we can build a tool that can pound in nails.'" -- Alex Papadimoulis (on TheDailyWTF.com)

  7. #7
    ezadx10b is offline x10Hosting Member
    Join Date
    Feb 2012
    Posts
    29

    Re: Single error PHP file

    Quote Originally Posted by essellar View Post
    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.

  8. #8
    ezadx10b is offline x10Hosting Member
    Join Date
    Feb 2012
    Posts
    29

    Re: Single error PHP file

    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..

Similar Threads

  1. 403 Error when writing from php file to XML file
    By austrian2115 in forum Free Hosting
    Replies: 1
    Last Post: 10-19-2011, 01:25 PM
  2. Replies: 3
    Last Post: 09-11-2011, 05:57 AM
  3. Replies: 12
    Last Post: 09-17-2010, 10:47 PM
  4. PHP Single File Cron job
    By Shadow121 in forum Scripts, 3rd Party Apps, and Programming
    Replies: 0
    Last Post: 03-11-2009, 06:25 PM
  5. My new Hit Single
    By SEÑOR in forum Off Topic
    Replies: 2
    Last Post: 06-22-2008, 04:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
dedicated servers