Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2002
    Location
    Ohio
    Posts
    3,139

    Question custom error pages (in php)

    I'm working on some custom error pages I'm wanting to fully integrate into my phpnuke site, but I'm having a little problems.

    I added the following in my htaccess file:
    Code:
    ##
    ## Error Documents
    ##
    ErrorDocument 400 /errordocs.php?e=400
    ErrorDocument 401 /errordocs.php?e=401
    ErrorDocument 403 /errordocs.php?e=403
    ErrorDocument 404 /errordocs.php?e=404
    The script works fine when the failed request is for a file in the document root. Example: http://localhost/nosuch.file displayes the error page correctly, but when a file in a directory like http://localhost/somedirectory/nosuch.file and my images, and CSS doesnt show up.

    Here is my php code:

    PHP Code:
    include("mainfile.php");
    include(
    "header.php");

    if (
    $e == "400") {
            
    $errortitle ="Bad Request";
            
    $errormsg ="page text";
    } elseif (
    $e == "401") {
            
    $errortitle ="AUnauthorized!";
            
    $errormsg ="page text";
    } elseif (
    $e == "403") {
            
    $errortitle ="Forbidden!";
            
    $errormsg ="page text";
    } elseif (
    $e == "404") {
            
    $errortitle ="File Not found!";
            
    $errormsg ="page text";
    } else {
            
    $errortitle ="An Error has Occurred";
            
    $errormsg ="page text";
    }

    OpenTable();
    echo 
    "<center><font class=\"title\">$errortitle</font></center>";
    CloseTable();
    echo 
    "<br>";

    OpenTable();
    echo 
    "$errormsg";
    CloseTable();

    include(
    "footer.php");

    ?> 
    Hopefully I made a little sense

    Thanks in advance.
    Glioblastoma Multiforme (GBM) Brain Cancer Awareness. May is Brain Cancer awareness month. Gray Matters!
    Incurable, 6-18 months prognosis, survivors longer than 3 years less than 1% chance.
    Don't like what I say? Ignore me.

  2. #2
    Join Date
    Nov 2001
    Location
    California
    Posts
    1,991
    Use <base href="http://yoursite.com"> in the <HEAD> section of your code, this way all images and css will work.

  3. #3
    Join Date
    Jan 2002
    Location
    Ohio
    Posts
    3,139
    Thanks, it works great
    Glioblastoma Multiforme (GBM) Brain Cancer Awareness. May is Brain Cancer awareness month. Gray Matters!
    Incurable, 6-18 months prognosis, survivors longer than 3 years less than 1% chance.
    Don't like what I say? Ignore me.

  4. #4
    Join Date
    Nov 2001
    Location
    California
    Posts
    1,991
    Originally posted by MGCJerry
    Thanks, it works great

Posting Permissions

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